taxjar / taxjar-magento2-extension

Magento 2 Sales Tax Extension by TaxJar
http://www.taxjar.com/guides/integrations/magento2/
Open Software License 3.0
22 stars 30 forks source link

Address validation bug #66

Closed andrew-ebsco closed 5 years ago

andrew-ebsco commented 5 years ago

Hello TaxJar!

When Magento 2 is set to production mode, the TaxJar address validation mixins are still deployed in setup:static-content:deploy, even if address validation is not enabled. As a result, on the customer account edit address page (customer/address/edit), the taxjar/module-taxjar/view/base/web/js/address_validation.js is loaded on the page. Since the element #tj-suggested-addresses is not in the DOM because address validation is disabled, the mixin causes an error. The error prevents the normal Magento validation from being enabled and the required fields in the form are allowed to be submitted even if they are empty.

I was able to resolve the issue by creating my own mixin that overrides the TaxJar behavior by first checking if #tj-suggested-addresses exists in the DOM.

define([
    'jquery',
    'Taxjar_SalesTax/js/address_validation'
], function ($, tjAddressValidation) {
    'use strict';

    return function (addressValidation) {
        if (!$('#tj-suggested-addresses').length) {
            return;
        }

        return tjAddressValidation(addressValidation);
    };
});

Here are our relevant specs in case you need it:

Magento Commerce 2.3.1
PHP 7.2.18

Let me know if I can provide any more information.

Thanks!

ryanreeves-taxjar commented 5 years ago

Thanks for reporting this issue @andrew-ebsco! We're going to test this issue internally, and if it's reproducible we'll get a fix out shortly.

ryanreeves-taxjar commented 5 years ago

Hey @andrew-ebsco, we've created a PR with a fix for this issue here: https://github.com/taxjar/taxjar-magento2-extension/pull/67

Thanks for your help in reporting and fixing this!

fastdivision commented 5 years ago

Fixed in #67

andrew-ebsco commented 5 years ago

Thanks for the update!