addressfinder / addressfinder-magento Goto Github PK
View Code? Open in Web Editor NEWAddressFinder extension for Magento 2
License: Other
AddressFinder extension for Magento 2
License: Other
In formation about the customer here
Version: 2.4
There are a number of errors occurring on the page. Not sure if these are related to the issue or not.
Investigation required.
Testing issues:
Seems like the problem is to do with the country variable:
$country = $this->countryInformationAcquirer->getCountryInfo($countryCode);
@bencorlett any ideas?
We have had a report of the addressfinder-magento
plugin not working in a certain scenario.
This is the scenario:
Note: the widget attached to the shipping address field works as expected.
Website that demonstrates the problem: https://www.betterbatt.com.au/
There is a good thread of technical information here in Hubspot: https://app.hubspot.com/live-messages/20223507/inbox/1367525481#comment-editor
In short - we need to support an additional form configuration to make this scenario work.
You can see the currently generated formsConfig
on the BetterBatt checkout page here:
For the widget to work on BetterBatt (billing), we will need an additional formsConfig
hash for frontend.checkout.billing.address.shared
Here is the field that our searchIdentifier
is attempting to find:
The code which defines this data is here: https://github.com/AddressFinder/addressfinder-magento/blob/develop/Observer/FormConfig/Frontend/AddCheckoutBillingAddress.php#L54
This depends on the function getActivePaymentMethodCodes
. It appears that the OneStepCheckout people are suggesting that this function should also return shared
in its response.
The Magento plugin code is currently all minified in the browser, which makes it difficult for anyone except us to debug it. This is not great for open source.
A good solution is to use sourcemaps. This is a special file that connects a minified/uglified version of an asset to the original authored version. You can set this as an option for webpack. There is no performance hit because sourcemaps don't get loaded unless you have dev tools open. This would make it easier for both us and other users to debug 🎉
There are two steps
The changes themselves are small, but testing and deploying will take a while since we are changing the minification process of the webpage tools, and deploying to 3 different platforms
Hi Team,
We have upgrade our project and we are using Hyva Theme (https://www.hyva.io/) while installing the AddressFinder module we are facing lot of issue.
Just wanted to know do we have hyva compatible module so we can use the AddressFinder.
Thank you
Karuna Khatri
When debug mode is switched on I see this console log.
Page is triggering a large amount of mutations, which may prevent AddressFinder from working, and will slow down your store.
Sorry I don't quite understand what this means, would someone be able to elobrate?
This time it is on a Magento 2.3.2 website with a WeltPixel theme installed via composer from this documentation.
https://addressfinder.nz/docs/magento/
Address lookup does not appear to be working, although they could have modified the checkout form/template, is this mutations warning onto something here or can I ignore it?
Would having the Magento 2 site in production mode lower mutations and make Address Finder work?
Do I have to tweak these values higher?
this.millisecondsToIgnoreMutations = 750; // The amount of times the page can mutate in a row without forcing AddressFinder to be reinitialised.
this.maxMutationTimeoutCount = 20; // The count of the times the page has mutated in a row
Or is the DOM modified from what AddressFinder expects?
I did see a guide for how to fix that if so on the readme.
In reference to this issue: #21
We may want to expose the select handlers so devs can define their own. Seems like a good idea to be, but this change would be in webpage tools so would need to be rolled out to the other plugins -- so is medium effort. But we could start with Magento 2
Hey all :)
I can see that a recent update was aimed at selecting regions/states when they're presented as a dropdown. This code makes an assumption of the internal identifier for each state, IDs 569
through to 575
. In a standard Magento installation where there are no additional regions/states are added are actually 512
through to 519
. Irrespective of this, I don't think we can rely on the internal identifier for the most part:
<select class="select" name="region_id" id="O2G8HJQ" aria-describedby="notice-O2G8HJQ" placeholder="">
<option value="">Please select a region, state or province.</option>
<option data-title="Australian Capital Territory" value="512">Australian Capital Territory</option>
<option data-title="New South Wales" value="513">New South Wales</option>
<option data-title="Northern Territory" value="514">Northern Territory</option>
<option data-title="Queensland" value="515">Queensland</option>
<option data-title="South Australia" value="516">South Australia</option>
<option data-title="Tasmania" value="517">Tasmania</option>
<option data-title="Victoria" value="518">Victoria</option>
<option data-title="Western Australia" value="519">Western Australia</option>
</select>
In the Magento 1 extension, I introduced the concept of transformers. These are arbitrary and are used to transform a value returning from the AddressFinder API (e.g. New South Wales) into a value within Magento (e.g. 513, or 570, whatever it is in each installation).
We passed the transformer configuration through from server-side, by pulling out all regions/state mappings.
It might require a sizeable refactor to inject this configuration into the Magento 2 extension. Happy to explore this idea, have you got a preference on the way you'd like to attack it?
@1mattramsay, could you move this into done and close it once v1.4.2 has been accepted on the Magento marketplace?
Blocked: Waiting on Ben to provide feedback
If you have more than one payment method on your Magento checkout, AddressFinder will only load for the first form.
Currently we detect whether to reload AddressFinder based on 2 rules - whether all the form elements are still in the dom, and whether the layout selector has a 'display:none' style.
On this payment page the display:none style is applied to a different element. It is difficult to detect which of the forms is active/visible, as they are for the most part identical.
Current solution is to hard code specifics of each form as address form configurations: https://github.com/abletech/addressfinder-magento/pulls. This solution is ok, but potentially quite brittle.
@1mattramsay I am going to close this issue because I can't reproduce it with the latest version of our Magento plugin - I think it must have been fixed somewhere along the way to v1.4.0 👍
After upgrading Magento 2.4 to 2.4.2 the following exception occurs on /checkout/ page load which results in a blank page:
<script>
--
| require(['magento_plugin', 'addressfinder', 'domReady!'], function (MagentoPlugin, AddressFinder) {
| var widgetConfig = {"key":"*******************","options":{"address_params":{"au_paf":"1"}},"debug":true,"default_country":"au"};
| var formsConfig = An error has happened during application run. See exception log for details.
Output in system.log:
[2021-03-06 04:03:36] main.CRITICAL: Error: Call to a member function getPayment() on null in /home/realbasi/madge/vendor/stripe/module-payments/Model/Method/Express.php:29
Stack trace:
#0 /home/realbasi/madge/vendor/magento/module-payment/Helper/Data.php(146): StripeIntegration\Payments\Model\Method\Express->isAvailable(NULL)
#1 /home/realbasi/madge/vendor/addressfinder/module-magento2/Observer/FormConfig/Frontend/AddCheckoutBillingAddress.php(132): Magento\Payment\Helper\Data->getStoreMethods()
#2 /home/realbasi/madge/vendor/addressfinder/module-magento2/Observer/FormConfig/Frontend/AddCheckoutBillingAddress.php(41): AddressFinder\AddressFinder\Observer\FormConfig\Frontend\AddCheckoutBillingAddress->getActivePaymentMethodCodes()
#3 /home/realbasi/madge/vendor/addressfinder/module-magento2/Observer/FormConfig/Base.php(52): AddressFinder\AddressFinder\Observer\FormConfig\Frontend\AddCheckoutBillingAddress->addForm(Object(Magento\Framework\Data\Collection\Interceptor))
#4 /home/realbasi/madge/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): AddressFinder\AddressFinder\Observer\FormConfig\Base->execute(Object(Magento\Framework\Event\Observer))
#5 /home/realbasi/madge/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(AddressFinder\AddressFinder\Observer\FormConfig\Frontend\AddCheckoutBillingAddress), Object(Magento\Framework\Event\Observer))
#6 /home/realbasi/madge/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#7 /home/realbasi/madge/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('addressfinder_f...', Array)
#8 /home/realbasi/madge/vendor/addressfinder/module-magento2/Model/FormConfigProvider.php(75): Magento\Framework\Event\Manager\Proxy->dispatch('addressfinder_f...', Array)
#9 /home/realbasi/madge/vendor/addressfinder/module-magento2/Block/Plugin.php(59): AddressFinder\AddressFinder\Model\FormConfigProvider->get('addressfinder_f...')
#10 /home/realbasi/madge/var/view_preprocessed/pub/static/vendor/addressfinder/module-magento2/view/frontend/templates/plugin.phtml(4): AddressFinder\AddressFinder\Block\Plugin->getFormsConfig()
#11 /home/realbasi/madge/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/home/realbasi/...')
I note you have this on your todo list already so perhaps you're already aware of this issue - but seems you need to update the getActivePaymentMethodCodes() method in AddCheckoutBillingAddress observer to use the Api method instead. After testing with below code the exception no longer occurs and addressfinder works as expected.
private function getActivePaymentMethodCodes(): array
{
$codes = [];
// @todo Visit working around deprecated code
$paymentApi = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Payment\Api\PaymentMethodListInterface::class);
$storeId = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId();
foreach ($paymentApi->getActiveList($storeId) as $method) {
try {
$codes[] = $method->getCode();
} catch (LocalizedException $e) {
}
}
return $codes;
}
Result:
<script>
--
| require(['magento_plugin', 'addressfinder', 'domReady!'], function (MagentoPlugin, AddressFinder) {
| var widgetConfig = {"key":"********************","options":{"address_params":{"au_paf":"1"}},"debug":true,"default_country":"au"};
| var formsConfig = [{"id":"frontend.checkout.billing.address.payflow_express","label":"Checkout Billing Address (payflow_express)","layoutSelectors":["li#payment","div[name=\"billingAddresspayflow_express.street.0\"]"],"countryIdentifier":"div[name=\"billingAddresspayflow_express.country_id\"] select[name=country_id]","searchIdentifier":"div[name=\"billingAddresspayflow_express.street.0\"] input[name=\"street[0]\"]","nz":{"countryValue":"NZ","elements":{"address1":"div[name=\"billingAddresspayflow_express.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspayflow_express.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspayflow_express.street.2\"] input[name=\"street[2]\"]","city":"div[name=\"billingAddresspayflow_express.city\"] input[name=city]","region":"div[name=\"billingAddresspayflow_express.region\"] input[name=region]","postcode":"div[name=\"billingAddresspayflow_express.postcode\"] input[name=postcode]"},"regionMappings":null},"au":{"countryValue":"AU","elements":{"address1":"div[name=\"billingAddresspayflow_express.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspayflow_express.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspayflow_express.city\"] input[name=city]","state":"div[name=\"billingAddresspayflow_express.region_id\"] select[name=region_id]","postcode":"div[name=\"billingAddresspayflow_express.postcode\"] input[name=postcode]"},"stateMappings":{"ACT":569,"NSW":570,"NT":576,"QLD":572,"SA":573,"TAS":574,"VIC":571,"WA":575}}},{"id":"frontend.checkout.billing.address.paypal_express_bml","label":"Checkout Billing Address (paypal_express_bml)","layoutSelectors":["li#payment","div[name=\"billingAddresspaypal_express_bml.street.0\"]"],"countryIdentifier":"div[name=\"billingAddresspaypal_express_bml.country_id\"] select[name=country_id]","searchIdentifier":"div[name=\"billingAddresspaypal_express_bml.street.0\"] input[name=\"street[0]\"]","nz":{"countryValue":"NZ","elements":{"address1":"div[name=\"billingAddresspaypal_express_bml.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspaypal_express_bml.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspaypal_express_bml.street.2\"] input[name=\"street[2]\"]","city":"div[name=\"billingAddresspaypal_express_bml.city\"] input[name=city]","region":"div[name=\"billingAddresspaypal_express_bml.region\"] input[name=region]","postcode":"div[name=\"billingAddresspaypal_express_bml.postcode\"] input[name=postcode]"},"regionMappings":null},"au":{"countryValue":"AU","elements":{"address1":"div[name=\"billingAddresspaypal_express_bml.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspaypal_express_bml.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspaypal_express_bml.city\"] input[name=city]","state":"div[name=\"billingAddresspaypal_express_bml.region_id\"] select[name=region_id]","postcode":"div[name=\"billingAddresspaypal_express_bml.postcode\"] input[name=postcode]"},"stateMappings":{"ACT":569,"NSW":570,"NT":576,"QLD":572,"SA":573,"TAS":574,"VIC":571,"WA":575}}},{"id":"frontend.checkout.billing.address.payflow_express_bml","label":"Checkout Billing Address (payflow_express_bml)","layoutSelectors":["li#payment","div[name=\"billingAddresspayflow_express_bml.street.0\"]"],"countryIdentifier":"div[name=\"billingAddresspayflow_express_bml.country_id\"] select[name=country_id]","searchIdentifier":"div[name=\"billingAddresspayflow_express_bml.street.0\"] input[name=\"street[0]\"]","nz":{"countryValue":"NZ","elements":{"address1":"div[name=\"billingAddresspayflow_express_bml.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspayflow_express_bml.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspayflow_express_bml.street.2\"] input[name=\"street[2]\"]","city":"div[name=\"billingAddresspayflow_express_bml.city\"] input[name=city]","region":"div[name=\"billingAddresspayflow_express_bml.region\"] input[name=region]","postcode":"div[name=\"billingAddresspayflow_express_bml.postcode\"] input[name=postcode]"},"regionMappings":null},"au":{"countryValue":"AU","elements":{"address1":"div[name=\"billingAddresspayflow_express_bml.street.0\"] input[name=\"street[0]\"]","address2":"div[name=\"billingAddresspayflow_express_bml.street.1\"] input[name=\"street[1]\"]","suburb":"div[name=\"billingAddresspayflow_express_bml.city\"] input[name=city]","state":"div[name=\"billingAddresspayflow_express_bml.region_id\"] select[name=region_id]","postcode":"div[name=\"billingAddresspayflow_express_bml.postcode\"] input[name=postcode]"},"stateMappings":{"ACT":569,"NSW":570,"NT":576,"QLD":572,"SA":573,"TAS":574,"VIC":571,"WA":575}}},{"id":"frontend.checkout.billing.address.free","label":"Checkout Billing Address (free)","layoutSelectors":
... truncated...
This would be a change in webpage tools and would benefit all plugins
Might be a question for the Address Finder end but.
Is there a way to prevent web browser address auto complete to enforce using Address Finder or to make it play nicer?
Add docker container to simplify maintenance as well as allowing switching Magento version easily.
Set up different localhost URLs for the different versions.
Update to version v1.2.5
Currently we depend on the value of the country select box to set the widget active country. This means that the widget won't work if it is removed. In the WooCommerce plugin we allow users to set a default country for AddressFinder in the config options. We could do something like this for Magento.
To make this change we have to add another field to the Magento admin panel to get the default country.
However, this fix won't solve this issue: #21. This scenario is either
The fix for this would be a change to the webpage tools. We could initialise the widget with the default country if one is defined, rather than the value of the country element. I'm not sure if we should do this, because in some scenarios the country element and the widget country could end up out of sync
Currently the version number exposed in _magentoPlugin is actually the version number of the webpage tools which is confusing for debugging. We should have both version numbers exposed:
window.AddressFinder._magentoPlugin = { version: 1.2.1, webpage-tools-version: 1.6.0 }
Matt, please deploy to Magento Marketplace:
v1.2.3
addressfinder_addressfinder-1.2.3.zip
Matt can you deploy this to the Magento Marketplace?
Version 1.2.2:
addressfinder_addressfinder-1.2.2.zip
When JS minification is enabled the endpoint for minified widget.js file returns 404
Minified file URL https://api.addressfinder.io/assets/v3/widget.min.js does not exist.
Do you maybe have in plan to allow the minified file version of
https://api.addressfinder.io/assets/v3/widget.js
Thank you.
Our layout selectors are looking for 'li#opc-shipping_method' and 'li#payment' but we have found a customer who has 'div#opc-shipping_method' and 'div#payment' elements. AddressFinder does not work for this customer.
Could these selectors be updated to just '#opc-shipping_method' and '#payment'?
I cannot use Amasty RecurringPayments model with Address finder Module.
Getting below error When activating the module.
Magento 2.4.3
require(['magento_plugin', 'addressfinder', 'domReady!'], function (MagentoPlugin, AddressFinder) {
var widgetConfig = {"nzKey":"XXX","auKey":"XXX","nzWidgetOptions":null,"auWidgetOptions":null,"debug":false,"defaultCountry":"au"};
var formsConfig = TypeError: Argument 1 passed to Amasty\RecurringPayments\Model\QuoteValidate::validateQuote() must implement interface Magento\Quote\Api\Data\CartInterface, null given, called in /var/www/html/bsc-magento2.4.-/codepool/vendor/amasty/module-recurring-payments-paypal/Model/Method/Paypal.php on line 63 and defined in /var/www/html/bsc-magento2.4.-/codepool/vendor/amasty/recurring-payments/Model/QuoteValidate.php:44
Stack trace:
The CEv2.4 has been released and the plugin.
The current version of the AddressFinder Magento 2 plugin is not compatible with v2.4.
Release notes: https://devdocs.magento.com/guides/v2.4/release-notes/release-notes-2-4-0-open-source.html
A customer has provided the following information regarding compatibility.
We have developing site on Magento 2.3.5. And using:
"addressfinder/module-magento2": "^1.5"
Now we need to update Magento to 2.4. And this module has errors with composer updating.
Need to add "magento/framework" v103 to the "require" section in "composer.json".
Requires PHP 7.4.9
Extension currently supports up to PHP 7.3.
Our current version is 1.7 and this is the one which we will update.
The parser isn't handling multi line entries to the widget options
@1mattramsay, this one has also been resolved by Ben's updates so I will close 👍
Steps to reproduce.
$('form .control select').select2()
).Expected result:
Actual result:
<ul class="af_list">
is emptyHello,
I do not have a Country select box on the checkout as the store only services one country NZ, the widget appears to be defaulting to AU.
This module is all minified so I can't easily debug any chance of releasing non minified?
As I would also like to add a custom JS handler to do something with the meta data x,y location.
selected by the user such as.
function onNZAddressSelected(selectedAddress, metaData) {
console.log(metaData.x, metaData.y);
// Probably a better way.
$(this.element).parent().parent().parent().parent().parent().find("input[name=af_x]").val(metaData.x);
$(this.element).parent().parent().parent().parent().parent().find("input[name=af_y]").val(metaData.y);
}
widget.nz.on('result:select', onNZAddressSelected);
I have done this before with an older version, of the widget which seems to have since disappeared from github.
Previous was: addressfinder/module-magento2 version 1.1.1
window.AddressFinder._magentoPlugin.widgetConfig shows an AU Key is configured.
Could you please point me in the right direction to make these kinds of configurations if possible?
Kind regards,
In some scenarios, the widgetConfig.defaultCountry
is not set - and this causes issues when the widget is activated.
I believe the root cause of the problem is this line: https://github.com/AddressFinder/addressfinder-magento/blob/develop/view/base/web/js/source/magento-plugin.js#L35
defaultCountry: this.widgetConfig.default_search_country
I think the default_search_country
key is confined to PHP, and should not be used in JS/HTML. Here is the place where PHP configuration is prepared for conversion to JS - https://github.com/AddressFinder/addressfinder-magento/blob/develop/Model/WidgetConfigProvider.php#L98
This should be the last place that default_search_country
is referred to. From this point onwards, it looks like default_country
is the new key. I believe that default_country is translated into JS syntax as defaultCountry Not correct.
And I think that this block of PHP config is invected into the HTML here (note the json_encode
function call): https://github.com/AddressFinder/addressfinder-magento/blob/develop/view/frontend/templates/plugin.phtml#L11
We have 3 different keys which are mis-matched, and need to be understood why - and perhaps fixed/aligned:
There is an email trail of attempting to provide a workaround for this problem here: https://app.hubspot.com/live-messages/20223507/inbox/1481277347
The ultimate solution that got it going was change
file: view/frontend/web/js/magento-plugin.js
line: 148
from: defaultCountry: this.widgetConfig.default_search_country
to: defaultCountry: this.widgetConfig.default_country
Trying to install the extension via composer with Adobe Commerce 2.4.4 and not able to download the package because of composer dependency on PHP version below 8. Using PHP8.1.
Do you have plans to update the extension?
Readme currently has instructions for deploying the Magento 2 plugin. These should be moved to a DEPLOYMENT.md file. The readme should contain helpful information about how to install the Magento 2 plugin, and the guidelines for open source contribution. These guidelines could become the template for the other plugins and would make it more likely for outside developers to submit pull requests
New version of Magento that needs testing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.