Giter VIP home page Giter VIP logo

addressfinder-magento's People

Contributors

1mattramsay avatar bencorlett avatar dependabot[bot] avatar liamkarlmitchell avatar naikipl avatar nigelramsay avatar rickardd avatar vprigent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

addressfinder-magento's Issues

Magento 2 - updates to fix state mapping and mutiple payments

Testing issues:

  1. I couldn't get the updates to work on Magento v2.1. In the system.log this error is thrown:

Screen Shot 2019-12-10 at 1 08 48 PM

Seems like the problem is to do with the country variable:
$country = $this->countryInformationAcquirer->getCountryInfo($countryCode);
@bencorlett any ideas?

  1. RESOLVED: For Australian addresses, the suburb value is being populated into a different field. Normally, we add suburb values to the 'city' field, but now it is added to the 'street[2]' field. The image shows 'YAAPEET' in the street[2] field, and the city from a previous New Zealand address I searched remains in the city field.

Screen Shot 2019-12-10 at 12 19 09 PM

Add support for billing address for bank transfer payments

We have had a report of the addressfinder-magento plugin not working in a certain scenario.

This is the scenario:

  1. Using "one step checkout" plugin
  2. Selecting "I have a different billing address"
  3. Trying to enter the street address

Note: the widget attached to the shipping address field works as expected.

image

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

Fixing

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:

image

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:

image

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.

https://github.com/AddressFinder/addressfinder-magento/blob/master/Observer/FormConfig/Frontend/AddCheckoutBillingAddress.php#L127

Magento source maps

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

  1. Export the non-minified addressfinder-webpage-tools package by. This file can be minified by the plugins themselves.
  2. Add sourcemaps to the webpack config of each of the plugins. There is an example of this already in the WooCommerce plugin.

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

Hyva Theme compatibility issues

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

Too many mutations prevent AddressFinder from working? identifiedFormHelperConfig is empty array.

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

image

Or is the DOM modified from what AddressFinder expects?

image

I did see a guide for how to fix that if so on the readme.

State Mapping

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:

Screen Shot 2019-09-04 at 2 00 11 pm

<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?

  • Ben.

Magento 2 Plugin doesn't handle multiple address forms on the payments page

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.

MAGENTO_BUG1
MAGENTO_BUG2
MAGENTO_BUG_3

getActivePaymentMethodCodes Exception on Checkout page - Magento 2.4.2

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... 

Dockerise Magento installation

Details

Add docker container to simplify maintenance as well as allowing switching Magento version easily.

Set up different localhost URLs for the different versions.

Completion criterias

  • We can easily run a docker container for different computers.
  • We can test different Magento versions by changing the URL in the browser.

Magento refactoring

  • Update webpage tools to v1.8.1
  • Refactor the project structure
  • Plugin JavaScript Widget Config Injection

Enable users to set a default country

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

  1. The country field has been visually hidden from the page, but its value is set to Australia, and the customer wants to collect New Zealand addresses.
  2. Country element is removed from the page with javascript after AddressFinder has initialised, but it's value was set to Australia

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

Incorrect layout selector for Shipping checkout

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'?

Error with Amasty Recurring Payments model.

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:

Adjustments required for Magento v2.4 compatibility

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.

Magento 2.3 compatibility?

The module does not seem to be compatible with Magento 2.3 version.

As per dependency for magento/framework in composer.json
magento/framework: 100.0.*|100.1.*|101.0.*

Running composer require addressfinder/module-magento2 command breaks.
2019-02-11-11-10

select2 breaks the search.

Steps to reproduce.

  1. Init select2 on all dropdowns by default (put some *.phtml "before body end" file with JS: $('form .control select').select2()).
  2. Go to the Checkout page
  3. Select NZ country and start typing address

Expected result:

  • AddressFinder shows some result

Actual result:

  • <ul class="af_list"> is empty

How can I configure this to be NZ only mode with use nearby locations and add custom JS?

Hello,

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,

Fault with default country on checkout

In some scenarios, the widgetConfig.defaultCountry is not set - and this causes issues when the widget is activated.

image

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

Summary

We have 3 different keys which are mis-matched, and need to be understood why - and perhaps fixed/aligned:

  • default_search_country
  • default_country
  • defaultCountry

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

Compatibility with Adobe Commerce 2.4.4

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?

Improve readme for Magento 2 repo

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.