Paazl / magento2-checkout-widget

6 stars 15 forks source link

Unable to collect totals #56

Closed reense closed 3 years ago

reense commented 3 years ago

Hello,

Currently, we're getting the following exception on the cart page when calling getTotals() from 'Magento_Checkout/js/action/get-totals', to re-collect the totals: The shipping address is missing. Set the address and try again. This exception is thrown in the shopping cart, and not in the checkout. The user has not yet had the change to fill any address information. This is the full stack trace:

{
    "message": "The shipping address is missing. Set the address and try again.",
    "trace": "#0 \/Users\/reense\/Projects\/xxx\/vendor\/paazl\/magento2-checkout-widget\/Model\/Quote\/Totals\/AppendShippingMethods.php(66): Magento\\Quote\\Model\\ShippingMethodManagement->getList('328958')\n#1 \/Users\/reense\/Projects\/xxx\/vendor\/paazl\/magento2-checkout-widget\/Plugin\/Quote\/CartTotalRepositoryPlugin.php(47): Paazl\\CheckoutWidget\\Model\\Quote\\Totals\\AppendShippingMethods->append(Object(Magento\\Quote\\Model\\Cart\\Totals), '328958')\n#2 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(146): Paazl\\CheckoutWidget\\Plugin\\Quote\\CartTotalRepositoryPlugin->afterGet(Object(Magento\\Quote\\Model\\Cart\\CartTotalRepository\\Interceptor), Object(Magento\\Quote\\Model\\Cart\\Totals), '328958')\n#3 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Quote\\Model\\Cart\\CartTotalRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}('328958')\n#4 \/Users\/reense\/Projects\/xxx\/generated\/code\/Magento\/Quote\/Model\/Cart\/CartTotalRepository\/Interceptor.php(23): Magento\\Quote\\Model\\Cart\\CartTotalRepository\\Interceptor->___callPlugins('get', Array, Array)\n#5 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/module-quote\/Model\/GuestCart\/GuestCartTotalRepository.php(50): Magento\\Quote\\Model\\Cart\\CartTotalRepository\\Interceptor->get('328958')\n#6 [internal function]: Magento\\Quote\\Model\\GuestCart\\GuestCartTotalRepository->get('Gj2KwEAwNhoS8rT...')\n#7 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/module-webapi\/Controller\/Rest\/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#8 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/module-webapi\/Controller\/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#9 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#10 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#11 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#12 \/Users\/reense\/Projects\/xxx\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(23): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#13 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/App\/Http.php(116): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#14 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\Http->launch()\n#15 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\Http\\Interceptor->___callParent('launch', Array)\n#16 \/Users\/reense\/Projects\/xxx\/vendor\/yireo\/magento2-whoops\/Plugin\/HttpApp.php(103): Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#17 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Yireo\\Whoops\\Plugin\\HttpApp->aroundLaunch(Object(Magento\\Framework\\App\\Http\\Interceptor), Object(Closure))\n#18 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#19 \/Users\/reense\/Projects\/xxx\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(23): Magento\\Framework\\App\\Http\\Interceptor->___callPlugins('launch', Array, NULL)\n#20 \/Users\/reense\/Projects\/xxx\/vendor\/magento\/framework\/App\/Bootstrap.php(263): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#21 \/Users\/reense\/Projects\/xxx\/pub\/index.php(29): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#22 \/Users\/reense\/.composer\/vendor\/laravel\/valet\/server.php(191): require('\/Users\/reense\/P...')\n#23 {main}"
}

The exception is generated in the file Model/Quote/Totals/AppendShippingMethods.php, which calls $methods = $this->shippingMethodManagement->getList($quote->getId());, which probably works fine for the checkout but does not seem to work for the cart, because the ShippingMethodManagementInterface@getList method will thrown an exception when the country id is not set on the quote.

We wrote a preference for now to intercept the append method in AppendShippingMethod, and surround it with a try catch. However, that does not seem like a proper solution to me. Could you guys tell me if we're doing something wrong, or if the extension is kicking in on the wrong page.

Frank-Magmodules commented 3 years ago

Hi @reense, thank you for opening and reporting this issue. We have created an internal task for this issue and will try to come back to you as soon as possible. Thank you for your patience!

reense commented 3 years ago

@Frank-Magmodules Thanks! 🚀

Frank-Magmodules commented 3 years ago

Hi @reense ,

Seems we can't reproduce this issue and/or this exception in our environment. Can you please share some more information about your cart setup and how to reproduce this using our contact form so we can take a look with you on this?

reense commented 3 years ago

@Frank-Magmodules hmm, this is the url we call:

http://host.test/en/rest/en/V1/guest-carts/bx3BeSWUgo0cZHwsKtqxgYmeV4Qoml2l/totals?_=1619429419062

You can reproduce this by executing the following in your console:

require(['Magento_Checkout/js/action/get-totals'], function (totals) { 
    totals() 
});

On the cart page of any particular shop. Can you try and reproduce it with these steps? 🙂

Frank-Magmodules commented 3 years ago

Hi @reense, we have just released the v1.7.0 version that has a fix for this issue. Thanks for the detailed reports and patience. We are closing this issue now but please feel free to reopen the issue if this still occurs.

reense commented 3 years ago

@Frank-Magmodules thanks! This issue has been solved on our end. :)