Skip to content

Commit 94291a9

Browse files
Merge branch 'develop'
2 parents de5cf7a + 7f0fa28 commit 94291a9

File tree

17 files changed

+117
-32
lines changed

17 files changed

+117
-32
lines changed

Block/Adminhtml/Config/Support/Tab.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Tab extends Template implements RendererInterface
4040
{
4141
const MODULE_NAME = 'TIG_Postcode';
4242

43-
const EXTENSION_VERSION = '1.5.1';
43+
const EXTENSION_VERSION = '1.5.2';
4444

4545
// @codingStandardsIgnoreLine
4646
protected $_template = 'TIG_Postcode::config/support/tab.phtml';

Plugin/Checkout/Model/GuestPaymentInformationManagement.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ public function beforeSavePaymentInformation(
6464
$cartId,
6565
$email,
6666
PaymentInterface $paymentMethod,
67-
AddressInterface $address
67+
AddressInterface $address = null
6868
) {
69-
$extAttributes = $address->getExtensionAttributes();
70-
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
69+
if ($address) {
70+
$extAttributes = $address->getExtensionAttributes();
71+
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
72+
}
7173
}
7274
}

Plugin/Checkout/Model/PaymentInformationManagement.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ public function beforeSavePaymentInformation(
3232
\Magento\Checkout\Model\PaymentInformationManagement $subject,
3333
$cartId,
3434
PaymentInterface $paymentMethod,
35-
AddressInterface $address
35+
AddressInterface $address = null
3636
) {
37-
$extAttributes = $address->getExtensionAttributes();
38-
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
37+
if ($address) {
38+
$extAttributes = $address->getExtensionAttributes();
39+
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
40+
}
3941
}
4042
}

Plugin/Model/Checkout/LayoutProcessorPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function createHousenumberFieldsDefinition($dataScope)
152152
*/
153153
private function getParentPath($path, $delimiter = '/', $count = 1)
154154
{
155-
$splitPath = explode($delimiter, $path);
155+
$splitPath = !empty($path) ? explode($delimiter, $path) : [];
156156
for ($i = 0; $i < $count; $i++) {
157157
array_pop($splitPath);
158158
}

Plugin/Model/Osc/LayoutProcessorPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function createHousenumberFieldsDefinition($dataScope)
152152
*/
153153
private function getParentPath($path, $delimiter = '/', $count = 1)
154154
{
155-
$splitPath = explode($delimiter, $path);
155+
$splitPath = !empty($path) ? explode($delimiter, $path) : [];
156156
for ($i = 0; $i < $count; $i++) {
157157
array_pop($splitPath);
158158
}

Plugin/Model/ResourceModel/Country/CollectionPlugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(
7575
private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
7676
{
7777
return [
78-
'enabled' => $this->moduleConfiguration->isNLCheckEnabled(),
78+
'enabled' => $this->moduleConfiguration->isNLCheckEnabled() && !$this->moduleConfiguration->isModusOff(),
7979
'postcode' => [
8080
'sortOrder' => $sortOrderBase,
8181
'classes' => [
@@ -103,7 +103,7 @@ private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
103103
],
104104
'tig_street' => [
105105
'sortOrder' => $sortOrderBase + 3 * $sortOrderIncrement,
106-
'visible' => true,
106+
'visible' => false,
107107
'classes' => [
108108
'tig_street_field' => true,
109109
'tig_postcode_nl' => true
@@ -136,7 +136,7 @@ private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
136136
*/
137137
private function getPostcodeBEConfig($sortOrderBase, $sortOrderIncrement) {
138138
return [
139-
'enabled' => $this->moduleConfiguration->isBECheckEnabled(),
139+
'enabled' => $this->moduleConfiguration->isBECheckEnabled() && !$this->moduleConfiguration->isModusOff(),
140140
'postcode' => [
141141
'sortOrder' => $sortOrderBase,
142142
'classes' => [

README.md

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,89 @@
1-
# TIG Postcode validation Magento 2
1+
<p align="center"><img src="https://postcodeservice.com/wp-content/uploads/2021/01/postcode-service-logo__Logo-color.svg" width="300px" /></p>
22

3-
[![Coverage Status](https://coveralls.io/repos/github/tig-nl/postcode-magento2/badge.svg?branch=%28no+branch%29)](https://coveralls.io/github/tig-nl/postcode-magento2?branch=%28no+branch%29) [![Build Status](https://travis-ci.org/tig-nl/postcode-magento2.svg?branch=master)](https://travis-ci.org/tig-nl/postcode-magento2)
3+
# Postcode Service Magento 2
4+
[![Latest Stable Version](https://img.shields.io/github/v/release/tig-nl/postcode-magento2?style=for-the-badge&color=227cff)](https://github.com/tig-nl/postcode-magento2/releases/latest)
5+
![TIG Postcode Service 2.3.7 versions](https://img.shields.io/badge/Tested%20with%20Magento-2.3.7-%2300cf00?style=for-the-badge)
6+
![TIG Postcode Service 2.4.5 versions](https://img.shields.io/badge/Tested%20with%20Magento-2.4.5-%2300cf00?style=for-the-badge)
7+
[![Total Extension downloads](https://img.shields.io/packagist/dt/tig/postcode-magento2?style=for-the-badge&color=227cff)](https://packagist.org/packages/tig-nl/postcode-magento2/stats)
8+
![Build Status](https://img.shields.io/travis/tig-nl/postcode-magento2/master?style=for-the-badge)
49

5-
Install the extension with composer
10+
11+
## Requirements
12+
- Magento version 2.4.5, 2.4.4, 2.3.7 or 2.3.6
13+
- PHP 7.3+
14+
15+
## Installation
16+
We strongly recommend that you use a Staging Environment for the installation, and to also make a backup of your environment.
17+
18+
### Installation using composer (recommended)
19+
To install the extension login to your environment using SSH. Then navigate to the Magento 2 root directory and run the following commands in the same order as described:
20+
21+
Enable maintenance mode:
22+
~~~~shell
23+
php bin/magento maintenance:enable
624
~~~~
25+
26+
1. Install the extension:
27+
~~~~shell
728
composer require tig/postcode-magento2
829
~~~~
930

31+
2. Enable the Postcode Service Magento 2 extension
32+
~~~~shell
33+
php bin/magento module:enable TIG_Postcode
34+
~~~~
35+
36+
3. Update the Magento 2 environment:
37+
~~~~shell
38+
php bin/magento setup:upgrade
39+
~~~~
40+
41+
When your Magento environment is running in production mode, you also need to run the following comands:
42+
43+
4. Compile DI:
44+
~~~~shell
45+
php bin/magento setup:di:compile
46+
~~~~
47+
48+
5. Deploy static content:
49+
~~~~shell
50+
php bin/magento setup:static-content:deploy
51+
~~~~
52+
53+
6. Disable maintenance mode:
54+
~~~~shell
55+
php bin/magento maintenance:disable
56+
~~~~
57+
58+
### Installation manually
59+
1. Download the extension directly from [github](https://github.com/tig-nl/postcode-magento2) by clicking on *Code* and then *Download ZIP*.
60+
2. Create the directory *app/code/TIG/Postcode* (Case-sensitive)
61+
3. Extract the zip and upload the code into *app/code/TIG/Postcode*
62+
4. Enable the Postcode Service Magento 2 extension
63+
~~~~shell
64+
php bin/magento module:enable TIG_Postcode
65+
~~~~
66+
67+
5. Update the Magento 2 environment:
68+
~~~~shell
69+
php bin/magento setup:upgrade
70+
~~~~
71+
72+
## Update
73+
To update the Postcode Service Extension run the following commands:
74+
~~~~shell
75+
composer update tig/postcode-magento2
76+
php bin/magento setup:upgrade
77+
~~~~
78+
79+
## Examples
80+
81+
### Dutch Postcode Service within the Magento 2 checkout
82+
![Postcode Service Magento 2 Checkout NL](https://postcodeservice.com/wp-content/uploads/2022/08/postcodeservice-magento-2-nl.gif "Postcode Service Magento 2 Checkout NL")
83+
84+
### Belgium Postcode Service within the Magento 2 checkout
85+
![Postcode Service Magento 2 Checkout BE](https://postcodeservice.com/wp-content/uploads/2022/08/postcodeservice-magento-2-be.gif "Postcode Service Magento 2 Checkout NL")
1086

87+
## Documentation
1188
For further installation guidance
1289
https://developers.postcodeservice.com/

Services/Validation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function checkKeys($data)
9999
*/
100100
private function checkStreetNameValue($data)
101101
{
102-
if (strpos($data['straatnaam'], 'limiet bereikt') !== false) {
102+
if (strpos($data['straatnaam'] ?? '', 'limiet bereikt') !== false) {
103103
return false;
104104
}
105105

Test/Unit/Block/Adminhtml/Config/Support/TabTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TabTest extends TestCase
4242
public function testGetVersionNumber()
4343
{
4444
$instance = $this->getInstance();
45-
$this->assertSame('1.5.1', $instance->getVersionNumber());
45+
$this->assertSame('1.5.2', $instance->getVersionNumber());
4646
}
4747

4848
public function testGetSupportedMagentoVersions()
@@ -51,7 +51,7 @@ public function testGetSupportedMagentoVersions()
5151
'moduleConfiguration' => $this->getConfigurationMock()
5252
]);
5353

54-
$this->assertSame('2.3.7, 2.4.4', $instance->getSupportedMagentoVersions());
54+
$this->assertSame('2.3.7, 2.4.5-p1', $instance->getSupportedMagentoVersions());
5555
}
5656

5757
/**+
@@ -62,7 +62,7 @@ private function getConfigurationMock()
6262
$mock = $this->getFakeMock(ModuleConfiguration::class)->getMock();
6363
$mockExpects = $mock->expects($this->once());
6464
$mockExpects->method('getSupportedMagentoVersions');
65-
$mockExpects->willReturn('2.3.7, 2.4.4');
65+
$mockExpects->willReturn('2.3.7, 2.4.5-p1');
6666

6767
return $mock;
6868
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"magento/module-quote": ">=101.0.5,<=101.0.11|~101.1|~101.2"
88
},
99
"type": "magento2-module",
10-
"version": "1.5.1",
10+
"version": "1.5.2",
1111
"license": "CC-BY-NC-ND-3.0",
1212
"authors": [
1313
{

0 commit comments

Comments
 (0)