magento / inventory

Magento Inventory Project (a.k.a MSI)
Open Software License 3.0
336 stars 247 forks source link

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) #3260

Open InternetAdvertisingSolutions opened 3 years ago

InternetAdvertisingSolutions commented 3 years ago

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.

m2-assistant[bot] commented 3 years ago

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


mrtuvn commented 3 years ago

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

torhoehn commented 3 years ago

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

mrtuvn commented 3 years ago

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 ?

torhoehn commented 3 years ago

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

torhoehn commented 3 years ago

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

TectonicKestrel commented 3 years ago

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:

#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]`

craig-bartlett commented 3 years ago

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 commented 3 years ago

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.

mrtuvn commented 3 years ago

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

naxrd commented 3 years ago

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.

malafalx91 commented 3 years ago

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.