Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-robertgrundeken committed Dec 19, 2022
2 parents de5cf7a + 7f0fa28 commit 94291a9
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Config/Support/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Tab extends Template implements RendererInterface
{
const MODULE_NAME = 'TIG_Postcode';

const EXTENSION_VERSION = '1.5.1';
const EXTENSION_VERSION = '1.5.2';

// @codingStandardsIgnoreLine
protected $_template = 'TIG_Postcode::config/support/tab.phtml';
Expand Down
8 changes: 5 additions & 3 deletions Plugin/Checkout/Model/GuestPaymentInformationManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ public function beforeSavePaymentInformation(
$cartId,
$email,
PaymentInterface $paymentMethod,
AddressInterface $address
AddressInterface $address = null
) {
$extAttributes = $address->getExtensionAttributes();
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
if ($address) {
$extAttributes = $address->getExtensionAttributes();
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
}
}
}
8 changes: 5 additions & 3 deletions Plugin/Checkout/Model/PaymentInformationManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public function beforeSavePaymentInformation(
\Magento\Checkout\Model\PaymentInformationManagement $subject,
$cartId,
PaymentInterface $paymentMethod,
AddressInterface $address
AddressInterface $address = null
) {
$extAttributes = $address->getExtensionAttributes();
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
if ($address) {
$extAttributes = $address->getExtensionAttributes();
$this->fieldsHelper->copyFieldsFromExtensionAttributesToObject($extAttributes, $address);
}
}
}
2 changes: 1 addition & 1 deletion Plugin/Model/Checkout/LayoutProcessorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function createHousenumberFieldsDefinition($dataScope)
*/
private function getParentPath($path, $delimiter = '/', $count = 1)
{
$splitPath = explode($delimiter, $path);
$splitPath = !empty($path) ? explode($delimiter, $path) : [];
for ($i = 0; $i < $count; $i++) {
array_pop($splitPath);
}
Expand Down
2 changes: 1 addition & 1 deletion Plugin/Model/Osc/LayoutProcessorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function createHousenumberFieldsDefinition($dataScope)
*/
private function getParentPath($path, $delimiter = '/', $count = 1)
{
$splitPath = explode($delimiter, $path);
$splitPath = !empty($path) ? explode($delimiter, $path) : [];
for ($i = 0; $i < $count; $i++) {
array_pop($splitPath);
}
Expand Down
6 changes: 3 additions & 3 deletions Plugin/Model/ResourceModel/Country/CollectionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(
private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
{
return [
'enabled' => $this->moduleConfiguration->isNLCheckEnabled(),
'enabled' => $this->moduleConfiguration->isNLCheckEnabled() && !$this->moduleConfiguration->isModusOff(),
'postcode' => [
'sortOrder' => $sortOrderBase,
'classes' => [
Expand Down Expand Up @@ -103,7 +103,7 @@ private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
],
'tig_street' => [
'sortOrder' => $sortOrderBase + 3 * $sortOrderIncrement,
'visible' => true,
'visible' => false,
'classes' => [
'tig_street_field' => true,
'tig_postcode_nl' => true
Expand Down Expand Up @@ -136,7 +136,7 @@ private function getPostcodeNLConfig($sortOrderBase, $sortOrderIncrement): array
*/
private function getPostcodeBEConfig($sortOrderBase, $sortOrderIncrement) {
return [
'enabled' => $this->moduleConfiguration->isBECheckEnabled(),
'enabled' => $this->moduleConfiguration->isBECheckEnabled() && !$this->moduleConfiguration->isModusOff(),
'postcode' => [
'sortOrder' => $sortOrderBase,
'classes' => [
Expand Down
83 changes: 80 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,89 @@
# TIG Postcode validation Magento 2
<p align="center"><img src="https://postcodeservice.com/wp-content/uploads/2021/01/postcode-service-logo__Logo-color.svg" width="300px" /></p>

[![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)
# Postcode Service Magento 2
[![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)
![TIG Postcode Service 2.3.7 versions](https://img.shields.io/badge/Tested%20with%20Magento-2.3.7-%2300cf00?style=for-the-badge)
![TIG Postcode Service 2.4.5 versions](https://img.shields.io/badge/Tested%20with%20Magento-2.4.5-%2300cf00?style=for-the-badge)
[![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)
![Build Status](https://img.shields.io/travis/tig-nl/postcode-magento2/master?style=for-the-badge)

Install the extension with composer

## Requirements
- Magento version 2.4.5, 2.4.4, 2.3.7 or 2.3.6
- PHP 7.3+

## Installation
We strongly recommend that you use a Staging Environment for the installation, and to also make a backup of your environment.

### Installation using composer (recommended)
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:

Enable maintenance mode:
~~~~shell
php bin/magento maintenance:enable
~~~~

1. Install the extension:
~~~~shell
composer require tig/postcode-magento2
~~~~

2. Enable the Postcode Service Magento 2 extension
~~~~shell
php bin/magento module:enable TIG_Postcode
~~~~

3. Update the Magento 2 environment:
~~~~shell
php bin/magento setup:upgrade
~~~~

When your Magento environment is running in production mode, you also need to run the following comands:

4. Compile DI:
~~~~shell
php bin/magento setup:di:compile
~~~~

5. Deploy static content:
~~~~shell
php bin/magento setup:static-content:deploy
~~~~

6. Disable maintenance mode:
~~~~shell
php bin/magento maintenance:disable
~~~~

### Installation manually
1. Download the extension directly from [github](https://github.com/tig-nl/postcode-magento2) by clicking on *Code* and then *Download ZIP*.
2. Create the directory *app/code/TIG/Postcode* (Case-sensitive)
3. Extract the zip and upload the code into *app/code/TIG/Postcode*
4. Enable the Postcode Service Magento 2 extension
~~~~shell
php bin/magento module:enable TIG_Postcode
~~~~

5. Update the Magento 2 environment:
~~~~shell
php bin/magento setup:upgrade
~~~~

## Update
To update the Postcode Service Extension run the following commands:
~~~~shell
composer update tig/postcode-magento2
php bin/magento setup:upgrade
~~~~

## Examples

### Dutch Postcode Service within the Magento 2 checkout
![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")

### Belgium Postcode Service within the Magento 2 checkout
![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")

## Documentation
For further installation guidance
https://developers.postcodeservice.com/
2 changes: 1 addition & 1 deletion Services/Validation/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function checkKeys($data)
*/
private function checkStreetNameValue($data)
{
if (strpos($data['straatnaam'], 'limiet bereikt') !== false) {
if (strpos($data['straatnaam'] ?? '', 'limiet bereikt') !== false) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions Test/Unit/Block/Adminhtml/Config/Support/TabTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TabTest extends TestCase
public function testGetVersionNumber()
{
$instance = $this->getInstance();
$this->assertSame('1.5.1', $instance->getVersionNumber());
$this->assertSame('1.5.2', $instance->getVersionNumber());
}

public function testGetSupportedMagentoVersions()
Expand All @@ -51,7 +51,7 @@ public function testGetSupportedMagentoVersions()
'moduleConfiguration' => $this->getConfigurationMock()
]);

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

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

return $mock;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"magento/module-quote": ">=101.0.5,<=101.0.11|~101.1|~101.2"
},
"type": "magento2-module",
"version": "1.5.1",
"version": "1.5.2",
"license": "CC-BY-NC-ND-3.0",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<tig_postcode>
<supported_magento_version>2.3.7, 2.4.4</supported_magento_version>
<supported_magento_version>2.3.7, 2.4.5-p1</supported_magento_version>
<stability/>
<configuration>
<modus>0</modus>
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Extension status,Extension status
"Can not find the address, please fill in manually","Can not find the address, please fill in manually"
"Housenumber","Housenumber"
"Addition","Addition"
"Housenumber addition","Housenumber addition"
"Please select a postcode before filling the street field.","Please select a postcode before filling the street field."
"Enable Netherlands check","Enable Netherlands check"
"Enable Belgium check","Enable Belgium check"
Expand Down
1 change: 1 addition & 0 deletions i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Disabled,Désactivé
"Can not find the address, please fill in manually","Adresse introuvable, veuillez la renseigner manuellement"
"Housenumber","Numéro"
"Addition","Complément d'adresse"
"Housenumber addition","Ajout de numéro de maison"
"Please select a postcode before filling the street field.","Veuillez sélectionner un code postal avant de renseigner le chanp Adresse"
"Enable Netherlands check","Activer la vérification pour les Pays-Bas"
"Enable Belgium check","Activer la vérification pour la Belgique"
Expand Down
6 changes: 3 additions & 3 deletions i18n/nl_BE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ Support,Support
"Support by phone","Telefonisch support"
"24/7 SLA support","24/7 SLA support"
"Can not find the address, please fill in manually","Het adres kan niet gevonden worden, vul alsjeblieft handmatig in"
"House number","Huisnummer"
"Housenumber","Huisnummer"
"Addition","Bus"

"Housenumber addition","Huisnummer toevoeging"
"Back-end merging","Back-end samenvoeging"
"These settings have impact on how street address data is stored in the database.","Deze instellingen hebben invloed op hoe adres data wordt opgeslagen in de database."
"Tampering with the settings may affect the workflow of third party extensions. Use at your own risk.","Het aanpassen van deze instellingen kan de werking van extensies van derden beïnvloeden. Gebruik op eigen risico."
"Street address field","Straatnaam veld"
"House number field","Huisnummer veld"
"House number addition field","Toevoeging veld"
"Housenumber addition field","Toevoeging veld"
"Street address line %1","Adres regel %1"
"These settings have no impact on the front-end.","Deze instellingen hebben geen invloed op de frontend."
"This extension is developed by Total Internet Group (TIG).","Deze instellingen hebben geen invloed op de frontend."
Expand Down
6 changes: 3 additions & 3 deletions i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ Support,Support
"Support by phone","Telefonisch support"
"24/7 SLA support","24/7 SLA support"
"Can not find the address, please fill in manually","Het adres kan niet gevonden worden, vul alsjeblieft handmatig in"
"House number","Huisnummer"
"Housenumber","Huisnummer"
"Addition","Toevoeging"

"Housenumber addition","Huisnummer toevoeging"
"Back-end merging","Back-end samenvoeging"
"These settings have impact on how street address data is stored in the database.","Deze instellingen hebben invloed op hoe adres data wordt opgeslagen in de database."
"Tampering with the settings may affect the workflow of third party extensions. Use at your own risk.","Het aanpassen van deze instellingen kan de werking van extensies van derden beïnvloeden. Gebruik op eigen risico."
"Street address field","Straatnaam veld"
"House number field","Huisnummer veld"
"House number addition field","Toevoeging veld"
"Housenumber addition field","Toevoeging veld"
"Street address line %1","Adres regel %1"
"These settings have no impact on the front-end.","Deze instellingen hebben geen invloed op de frontend."
"This extension is developed by Total Internet Group (TIG).","Deze instellingen hebben geen invloed op de frontend."
Expand Down
4 changes: 2 additions & 2 deletions view/base/web/js/postcode-handler/postcode-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ define([
*/
PostcodeHandler.prototype.reset = function() {
if (!('tig_postcode' in this.config) || this.config.tig_postcode['enabled'] === false) {
this.currentState = STATE_DISABLED;
this.setCurrentState(STATE_DISABLED);
return;
}

this.currentState = STATE_INIT;
this.setCurrentState(STATE_INIT);
this.postcodeService.setFieldsConfig(this.config.tig_postcode);
}

Expand Down
8 changes: 5 additions & 3 deletions view/base/web/js/postcode-handler/postcode-nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ define([
'underscore',
'./postcode-handler',
'../helper/field-types',
'../helper/postcode-api'
'../helper/postcode-api',
'mage/translate'
], function (
$,
_,
PostcodeHandler,
FieldTypes,
PostcodeApi
PostcodeApi,
$t
) {
'use strict';

Expand Down Expand Up @@ -84,7 +86,7 @@ define([

if (data.success !== true) {
self.setCurrentState(states.POSTCODE_CALL_FAILED);
self.getPostcodeService().getElement(FieldTypes.postcode).error('Sorry, we could not find the address on the given zip code and house number combination. If you are sure that the zip code and house number are correct, please fill in the address details manually.');
self.getPostcodeService().getElement(FieldTypes.postcode).error($t('Sorry, we could not find the address on the given zip code and house number combination. If you are sure that the zip code and house number are correct, please fill in the address details manually.'));
return;
}

Expand Down

0 comments on commit 94291a9

Please sign in to comment.