Skip to content

Commit 0527de5

Browse files
authored
Merge pull request #93 from JerrySmidt/master
3.3.0
2 parents 0831af6 + abe5108 commit 0527de5

34 files changed

+668
-421
lines changed

Block/System/Config/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function _getAccountInfo(): array
181181
{
182182
$status = $this->_storeConfigHelper->getValue(StoreConfigHelper::PATH['account_status']);
183183
if ($status === \Flekto\Postcode\Helper\ApiClientHelper::API_ACCOUNT_STATUS_ACTIVE) {
184-
return $this->_apiClientHelper->getApiClient()->accountInfo();
184+
return $this->_apiClientHelper->getAccountInfo();
185185
}
186186

187187
return [];

Helper/ApiClientHelper.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public function getAddressDetails(string $context): array
123123
$client = $this->getApiClient();
124124
$sessionId = $this->_getSessionId();
125125
$response = $client->internationalGetDetails($context, $sessionId);
126-
return $this->_prepareResponse($response, $client);
126+
$response = $this->_prepareResponse($response, $client);
127+
128+
return $response;
127129

128130
} catch (\Exception $e) {
129131
return $this->_handleClientException($e);
@@ -315,6 +317,16 @@ public function getCountryIso3Code(string $iso2Code): ?string
315317
return $this->_countryCodeMap[$mapKey][strtoupper($iso2Code)] ?? null;
316318
}
317319

320+
public function getAccountInfo(): array
321+
{
322+
try {
323+
return $this->getApiClient()->accountInfo();
324+
}
325+
catch (\Exception $e) {
326+
return [];
327+
}
328+
}
329+
318330
/**
319331
* _getModuleInfo function.
320332
*

Helper/StoreConfigHelper.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class StoreConfigHelper extends AbstractHelper
2828
// Advanced
2929
'api_debug' => 'postcodenl_api/advanced_config/api_debug',
3030
'disabled_countries' => 'postcodenl_api/advanced_config/disabled_countries',
31+
'allow_pobox_shipping' => 'postcodenl_api/advanced_config/allow_pobox_shipping',
3132

3233
// Status
3334
'module_version' => 'postcodenl_api/status/module_version',
@@ -177,8 +178,8 @@ public function getJsinit(): array
177178
'show_hide_address_fields' => $this->getValue(static::PATH['show_hide_address_fields']) ?? \Flekto\Postcode\Model\Config\Source\ShowHideAddressFields::SHOW,
178179
'base_url' => $this->getCurrentStoreBaseUrl(),
179180
'debug' => $this->isDebugging(),
180-
'fixedCountry' => $this->_getFixedCountry(),
181181
'change_fields_position' => $this->isSetFlag(static::PATH['change_fields_position']),
182+
'allow_pobox_shipping' => $this->isSetFlag(static::PATH['allow_pobox_shipping']),
182183
];
183184
}
184185

@@ -204,21 +205,4 @@ public function isDebugging(): bool
204205
{
205206
return $this->isSetFlag(static::PATH['api_debug'], ScopeInterface::SCOPE_STORE) && $this->_developerHelper->isDevAllowed();
206207
}
207-
208-
/**
209-
* Get fixed country (ISO2) if there's only one allowed country.
210-
*
211-
* @access private
212-
* @return string|null
213-
*/
214-
private function _getFixedCountry(): ?string
215-
{
216-
$allowedCountries = $this->getValue('general/country/allow');
217-
218-
if (isset($allowedCountries) && strlen($allowedCountries) === 2) {
219-
return $allowedCountries;
220-
}
221-
222-
return null;
223-
}
224208
}

README.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
![Postcode.eu](media/postcode-eu-logo-gradient.svg)
22

3-
# International Address API module for Magento 2
3+
## International Address API module for Magento 2
44

55
Adds autocompletion for addresses to the checkout page. [Multiple countries](https://www.postcode.nl/services/adresdata/internationaal) are supported using official postal data via the [Postcode.eu](https://postcode.eu) API.
66

77
This module is maintained by [Postcode.nl](https://postcode.nl) since version 3.0.0. Earlier versions were developed by [Flekto](https://www.flekto.nl).
88

9-
# Postcode.eu account
9+
## Postcode.eu account
1010

1111
A [Postcode.eu account](https://www.postcode.nl/en/services/adresdata/producten-overzicht) is required.
1212
Testing is free. After testing you can choose to purchase a subscription.
1313

14-
# Installation instructions
14+
## Installation instructions
1515

1616
1. Install this component using Composer:
1717

@@ -26,9 +26,9 @@ $ php bin/magento setup:di:compile
2626
$ php bin/magento cache:flush
2727
```
2828

29-
# Screenshots
29+
## Screenshots
3030

31-
## International Address API
31+
### International Address API
3232

3333
A single field for autocompletion:
3434

@@ -39,7 +39,7 @@ To allow users to skip the autocomplete field and manually enter an address, the
3939

4040
![](media/example-intl-api-manual-entry-option.png)
4141

42-
## Dutch Postcode API
42+
### Dutch Postcode API
4343

4444
Get a Dutch address by postcode and house number. In this example asking the user to select from valid house number additions:
4545

@@ -55,41 +55,26 @@ Other output options are:
5555
* Disable address fields until postcode and house number combination is valid.
5656
* No change; address fields remain visible and editable.
5757

58-
# Compatibility
58+
## Compatibility
5959

6060
Although we can't guarantee compatibility with other checkout modules, our module works well with most one-step-checkout modules. If you are having issues and think this may be caused by our module, please [contact Postcode.nl]([email protected]) and tell us which other module(s) and version(s) are used.
6161

6262
If you found the solution already and have some code to contribute, feel free to open a pull request in this repository.
6363

64-
## OneStepCheckout.com configuration instructions
65-
66-
1. Go to Stores -> Configuration -> Sales -> Postcode.eu Address API
67-
1. 'Change address fields position' to 'no'
68-
2. Go to Stores -> Configuration -> Sales -> OneStepCheckout
69-
1. The following fields need to be enabled for the billing **and** shipping fields:
70-
1. street.0
71-
2. postcode
72-
3. city
73-
4. region
74-
2. Add the following fields to the billing **and** shipping fields:
75-
1. address_autofill_nl.postcode
76-
2. address_autofill_nl.house_number
77-
3. address_autofill_nl.house_number_select
78-
4. address_autofill_intl
79-
5. address_autofill_formatted_output
80-
3. Optional: you may need to apply some custom CSS to display the fields correctly. You may set the region field to hidden.
64+
## Address API documentation
8165

66+
You can find our API documentation at https://developer.postcode.eu/documentation.
8267

83-
# Address API documentation
68+
## Module Wiki
8469

85-
You can find our API documentation at https://developer.postcode.eu/documentation.
70+
Instructions for additional configuration and customization can be found on the [wiki pages](https://github.com/postcode-nl/PostcodeNl_Api_Magento2/wiki).
8671

87-
# FAQ and Knowledge Base
72+
## FAQ and Knowledge Base
8873

8974
* View Frequently Asked Questions at https://www.postcode.eu/#faq.
9075
* For more questions and answers, see https://kb.postcode.nl/help
9176
* If the above didn't answer your question, [contact us](https://www.postcode.eu/contact).
9277

93-
# License
78+
## License
9479

9580
The code is available under the Simplified BSD License, see the included LICENSE file.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcode-nl/api-magento2-module",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
44
"description": "Postcode.eu International Address API module for Magento 2. Adds autocompletion for addresses in multiple countries using official postal data.",
55
"require": {
66
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3",

etc/adminhtml/system.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@
6262
<comment>Selected countries will have Address API disabled.</comment>
6363
<source_model>Flekto\Postcode\Model\Config\Source\DisabledCountries</source_model>
6464
</field>
65-
<field id="api_debug" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="100" translate="label" type="select" canRestore="1">
65+
<field id="allow_pobox_shipping" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="100" translate="label" type="select" canRestore="1">
66+
<label>PO box shipping</label>
67+
<comment>Allow shipping to PO boxes.</comment>
68+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
69+
</field>
70+
<field id="api_debug" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="110" translate="label" type="select" canRestore="1">
6671
<label>Debug</label>
6772
<comment/>
6873
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>

etc/config.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
<default>
44
<postcodenl_api>
55
<status>
6-
<module_version>3.2.0</module_version>
6+
<module_version>3.3.0</module_version>
77
<account_status>new</account_status>
88
</status>
99
<general>
1010
<enabled>1</enabled>
1111
<change_fields_position>1</change_fields_position>
1212
</general>
13+
<advanced_config>
14+
<allow_pobox_shipping>1</allow_pobox_shipping>
15+
</advanced_config>
1316
</postcodenl_api>
1417
</default>
1518
</config>

i18n/en_US.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
"An error has occurred while retrieving address data. Please contact us if the problem persists.","An error has occurred while retrieving address data. Please contact us if the problem persists."
4747
"Please select a house number.","Please select a house number."
4848
"Enter an address","Enter an address"
49-
"Please select an address from metropolitan France.","Please select an address from metropolitan France."
49+
"PO box shipping","PO box shipping"
50+
"Allow shipping to PO boxes.","Allow shipping to PO boxes."
51+
"Sorry, we cannot ship to a PO Box address.","Sorry, we cannot ship to a PO Box address."

i18n/nl_BE.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
"An error has occurred while retrieving address data. Please contact us if the problem persists.","Er is een fout opgetreden bij het ophalen van adres gegevens. Neem contact met ons op als het probleem blijft optreden."
4747
"Please select a house number.","Selecteer alstublieft een huisnummer."
4848
"Enter an address","Vul een adres in"
49-
"Please select an address from metropolitan France.","Selecteer een adres uit Europees Frankrijk."
49+
"PO box shipping","Postbus verzending"
50+
"Allow shipping to PO boxes.","Verzenden naar postbussen toestaan."
51+
"Sorry, we cannot ship to a PO Box address.","Sorry, we versturen niet naar een postbus adres."

i18n/nl_NL.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
"An error has occurred while retrieving address data. Please contact us if the problem persists.","Er is een fout opgetreden bij het ophalen van adres gegevens. Neem contact met ons op als het probleem blijft optreden."
4747
"Please select a house number.","Selecteer alstublieft een huisnummer."
4848
"Enter an address","Vul een adres in"
49-
"Please select an address from metropolitan France.","Selecteer een adres uit Europees Frankrijk."
49+
"PO box shipping","Postbus verzending"
50+
"Allow shipping to PO boxes.","Verzenden naar postbussen toestaan."
51+
"Sorry, we cannot ship to a PO Box address.","Sorry, we versturen niet naar een postbus adres."

0 commit comments

Comments
 (0)