inventory icon indicating copy to clipboard operation
inventory copied to clipboard

Magento 2.4.1 In-Store Delivery causes checkout to permanent hang with Error is email.js:165 Uncaught TypeError: Cannot read property 'check' of undefined at UiClass.validateEmail (email.js:165)

Open InternetAdvertisingSolutions opened this issue 4 years ago • 12 comments

Summary of the issue,

Magento 2.4.1 In-Store Delivery causes checkout to permanent hang when an existing customer enters their password. Checkout Page hangs with loading circle Error is email.js:165 Uncaught TypeError: Cannot read property 'check' of undefined at UiClass.validateEmail (email.js:165)

Preconditions (*)

  1. Magento CE 2.4.1
  2. Ubuntu 20.04
  3. MySQL8
  4. Apache2
  5. php7.4
  6. ElasticSearch 7.6
  7. Setup up Click-and-Collect as per Magento Instructions (Add source, assign stock, In-Store Pickup Delivery = enabled

Steps to reproduce (*)

  1. Do not log in as a customer
  2. Add an item to basket
  3. Go to checkout page
  4. Enter email address for existing customer
  5. Password field appears
  6. Enter password is entered
  7. Click Login

Expected result (*) Customers saved Delivery Address is shown and options of Delivery Methods including In-Stock Pickup should display underneath.

GitHub-ClickandCollect1

Actual result (*)

  1. Screen goes white with Loading circle and hangs permanently
  2. email.js:165 Uncaught TypeError: Cannot read property 'check' of undefined at UiClass.validateEmail (email.js:165) at UiClass.emailHasChanged (email.js:90) at setNested (objects.js:43) at Object.nested (objects.js:117) at UiClass.set (element.js:305) at updateValue (links.js:80) at Function.notifySubscribers (knockout.js:1320) at Function.valueHasMutated (knockout.js:1538) at UiClass.observable [as email] (knockout.js:1504) at setNested (objects.js:43)
  3. I know nothing about js but if it helps, /vendor/magento/module-checkout/view/frontend/web/js/view/form/elementEmail.js:165 line is return validator.check(usernameSelector);
  4. UPDATE - Subsequent tests show that the same error occurs for a new customer giving the same email.js error.

GitHub-ClickandCollect2

Thank You.

Hi @InternetAdvertisingSolutions. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Jan 08 '21 18:01 m2-assistant[bot]

are you sure this issue can reproduce in Open source edition ? I believe only you have Commerce edition will able to have option for reproduce problem

mrtuvn avatar Jan 09 '21 13:01 mrtuvn

@mrtuvn We also have this issue in Open source edition.

torhoehn avatar Jan 25 '21 10:01 torhoehn

Yeah i'm not sure that maybe code not cover all edge cases. Can we setup feature Click-and-Collect in vanilla magento open source ? I totally missed that. Any related links or docs wrap this ?

mrtuvn avatar Jan 25 '21 11:01 mrtuvn

I'll try to reproduce it here: https://github.com/magento/magento2/issues/31576

torhoehn avatar Jan 25 '21 12:01 torhoehn

@mrtuvn Unfortunately it's not possible without running indexer.

torhoehn avatar Jan 25 '21 14:01 torhoehn

I have this issue too on 2.4.1. I tried processing the order manually from the admin panel after a customer alerted me to this and got this error: Order saving error: Warning: array_merge(): Expected parameter 2 to be an array, object given in /var/www/vhosts/clicksaveandprint.com/httpdocs/vendor/magento/module-inventory-in-store-pickup-sales-admin-ui/Plugin/Sales/Model/AdminOrder/Create/AdaptSetShippingAddressPlugin.php on line 31.

Full error from system.log: main.CRITICAL: Exception message: Warning: array_merge(): Expected parameter 2 to be an array, object given in /var/www/vhosts/clicksaveandprint.com/httpdocs/vendor/magento/module-inventory-in-store-pickup-sales-admin-ui/Plugin/Sales/Model/AdminOrder/Create/AdaptSetShippingAddressPlugin.php on line 31 Trace: <pre>#1 array_merge() called at [vendor/magento/module-inventory-in-store-pickup-sales-admin-ui/Plugin/Sales/Model/AdminOrder/Create/AdaptSetShippingAddressPlugin.php:31] #2 Magento\InventoryInStorePickupSalesAdminUi\Plugin\Sales\Model\AdminOrder\Create\AdaptSetShippingAddressPlugin->aroundSetShippingAddress() called at [vendor/magento/framework/Interception/Interceptor.php:135] #3 Magento\Sales\Model\AdminOrder\Create\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #4 Magento\Sales\Model\AdminOrder\Create\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Model/AdminOrder/Create/Interceptor.php:230] #5 Magento\Sales\Model\AdminOrder\Create\Interceptor->setShippingAddress() called at [vendor/magento/module-sales/Model/AdminOrder/Create.php:1830] #6 Magento\Sales\Model\AdminOrder\Create->_prepareCustomer() called at [generated/code/Magento/Sales/Model/AdminOrder/Create/Interceptor.php:347] #7 Magento\Sales\Model\AdminOrder\Create\Interceptor->_prepareCustomer() called at [vendor/magento/module-sales/Model/AdminOrder/Create.php:1939] #8 Magento\Sales\Model\AdminOrder\Create->createOrder() called at [generated/code/Magento/Sales/Model/AdminOrder/Create/Interceptor.php:356] #9 Magento\Sales\Model\AdminOrder\Create\Interceptor->createOrder() called at [vendor/magento/module-sales/Controller/Adminhtml/Order/Create/Save.php:52] #10 Magento\Sales\Controller\Adminhtml\Order\Create\Save->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58] #11 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #12 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51] #13 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135] #14 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #15 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save/Interceptor.php:23] #16 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111] #17 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:151] #18 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #19 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #20 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143] #21 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #22 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #23 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save/Interceptor.php:32] #24 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186] #25 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118] #26 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #27 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #28 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #29 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23] #30 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116] #31 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23] #32 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:263] #33 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]

TectonicKestrel avatar Jan 28 '21 15:01 TectonicKestrel

We're seeing the same issue with 2.4.1 when logged in and loading the checkout page. We also have in-store delivery enabled with stock setup.

The error is triggered in app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js. I don't fully understand the logic but in our case the emailHasChanged callback fires when the value of email (checkoutData.getInputFieldEmailValue()) changes for some reason, which in turn calls validateEmail. This fails because the selector (form[data-role=email-with-possible-login]) cannot match the email field when it's not drawn.

I'm not sure why yet but the page loads with the email variable initially set to an empty string, but whilst loading the rest it changes to the user's email address and triggers the listener callback. I'm not good with KnockOut but will report my findings in case it's useful for someone else.

Edit - I should note that I get the same result in a clean install with Luma theme enabled, In-store delivery enabled and stock / sources configured.

craig-bartlett avatar Feb 09 '21 13:02 craig-bartlett

Hi,

It looks like it's caused by the Amazon_Payment module. In particular this line here. If enabled, the code in the initialize method changes the value of InputFieldEmailValue in checkoutData which then triggers the callback mentioned in my last post.

In our case I was able to fix this by disabling Amazon_Payment as we don't use it anyway, but I expect this may need to be posted over on that repository.

craig-bartlett avatar Feb 09 '21 14:02 craig-bartlett

Kill that module with fires. J/k External modules must update to compatible with magento. I believe module related from amazon need update to keep sync with workflow of magento. @craig-bartlett are you sure this module is included in magento ? @InternetAdvertisingSolutions

mrtuvn avatar Feb 09 '21 16:02 mrtuvn

I just added this lines:

if (typeof myVar == 'undefined') return true;

before the line:

return validator.check(usernameSelector);

In the file:

pub/static/frontend/Magento/luma/es_US/Magento_Checkout/js/view/form/element/email.js

And its working ok.

naxrd avatar Jun 09 '21 14:06 naxrd

Ciao,

Sembra che sia causato dal modulo Amazon_Payment. In particolare questa linea qui . Se abilitato, il codice nel metodo di inizializzazione cambia il valore di InputFieldEmailValue in checkoutData che quindi attiva il callback menzionato nel mio ultimo post.

Nel nostro caso sono stato in grado di risolvere questo problema disabilitando Amazon_Payment poiché non lo usiamo comunque, ma prevedo che potrebbe essere necessario pubblicarlo su quel repository.

Thanks for this thing here, in magento 2.4.2 I had the same problem, solved by removing the module I didn't use.

malafalx91 avatar Jul 29 '21 10:07 malafalx91