xcoreplatform / magento2-substituteorders

GNU General Public License v3.0
3 stars 9 forks source link

LocalizedException: This product is out of stock. #35

Closed davekleijn closed 2 years ago

davekleijn commented 4 years ago

When I try to reorder an order, I get an error message if one of the products is out of stock.

Steps to reproduce

  1. Go to my account
  2. Click on Order history
  3. Click on Reorder

Expected result

A user-friendly error message. Products that are in stock are placed in the shopping cart.

Actual result

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Dit product is niet op voorraad.

Exception #0 (Magento\Framework\Exception\LocalizedException): Dit product is niet op voorraad.
<pre>#1 Magento\Checkout\Model\Cart\Interceptor->addProduct() called at [vendor/magento/module-checkout/Model/Cart.php:287]
#2 Magento\Checkout\Model\Cart->addOrderItem() called at [generated/code/Magento/Checkout/Model/Cart/Interceptor.php:102]
#3 Magento\Checkout\Model\Cart\Interceptor->addOrderItem() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:137]
#4 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->reorderByOrderItems() called at [generated/code/Dealer4Dealer/SubstituteOrders/Controller/Order/Reorder/Interceptor.php:50]
#5 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->reorderByOrderItems() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:118]
#6 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->execute() called at [generated/code/Dealer4Dealer/SubstituteOrders/Controller/Order/Reorder/Interceptor.php:37]
#7 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#8 Magento\Framework\App\Action\Action->dispatch() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:91]
#9 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#10 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#11 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#12 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->___callPlugins() called at [generated/code/Dealer4Dealer/SubstituteOrders/Controller/Order/Reorder/Interceptor.php:26]
#13 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:159]
#14 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:99]
#15 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#16 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#17 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#18 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#19 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#20 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#21 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#22 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#23 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:137]
#24 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#25 Magento\Framework\App\Http\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#26 Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#27 Magento\Framework\App\Http\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:26]
#28 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#29 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:57]
Timothy-V commented 4 years ago

Getting a different error when trying to re-order with one of the products being out of stock. Magento 2.3.2 with SubstituteOrders 1.0.22

1 exception(s): Exception #0 (Exception): Warning: Division by zero in /data/web/magento2/vendor/magento/module-tax/Model/Calculation/AbstractAggregateCalculator.php on line 158

Exception #0 (Exception): Warning: Division by zero in /data/web/magento2/vendor/magento/module-tax/Model/Calculation/AbstractAggregateCalculator.php on line 158

#1 Magento\Tax\Model\Calculation\AbstractAggregateCalculator->calculateWithTaxNotInPrice() called at [vendor/magento/module-tax/Model/Calculation/AbstractCalculator.php:220]
#2 Magento\Tax\Model\Calculation\AbstractCalculator->calculate() called at [vendor/magento/module-tax/Model/TaxCalculation.php:284]
#3 Magento\Tax\Model\TaxCalculation->processItem() called at [vendor/magento/module-tax/Model/TaxCalculation.php:186]
#4 Magento\Tax\Model\TaxCalculation->calculateTax() called at [vendor/magento/module-tax/Model/Sales/Total/Quote/Subtotal.php:43]
#5 Magento\Tax\Model\Sales\Total\Quote\Subtotal->collect() called at [generated/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal/Interceptor.php:24]
#6 Magento\Tax\Model\Sales\Total\Quote\Subtotal\Interceptor->collect() called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:274]
#7 Magento\Quote\Model\Quote\TotalsCollector->collectAddressTotals() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#8 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#9 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/amasty/promo/Plugin/Quote/Model/Quote/TotalsCollectorPlugin.php:119]
#10 Amasty\Promo\Plugin\Quote\Model\Quote\TotalsCollectorPlugin->aroundCollectAddressTotals() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#11 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#12 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->___callPlugins() called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:52]
#13 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->collectAddressTotals() called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:148]
#14 Magento\Quote\Model\Quote\TotalsCollector->collect() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#15 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#16 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#17 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->___callPlugins() called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:39]
#18 Magento\Quote\Model\Quote\TotalsCollector\Interceptor->collect() called at [vendor/magento/module-quote/Model/Quote.php:1983]
#19 Magento\Quote\Model\Quote->collectTotals() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#20 Magento\Quote\Model\Quote\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#21 Magento\Quote\Model\Quote\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#22 Magento\Quote\Model\Quote\Interceptor->___callPlugins() called at [generated/code/Magento/Quote/Model/Quote/Interceptor.php:1066]
#23 Magento\Quote\Model\Quote\Interceptor->collectTotals() called at [vendor/magento/module-checkout/Model/Cart.php:580]
#24 Magento\Checkout\Model\Cart->save() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#25 Magento\Checkout\Model\Cart\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#26 Magento\Checkout\Model\Cart\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#27 Magento\Checkout\Model\Cart\Interceptor->___callPlugins() called at [generated/code/Magento/Checkout/Model/Cart/Interceptor.php:78]
#28 Magento\Checkout\Model\Cart\Interceptor->save() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:178]
#29 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->reorderByProduct() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:116]
#30 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#31 Magento\Framework\App\Action\Action->dispatch() called at [vendor/dealer4dealer/module-substituteorders/Controller/Order/Reorder.php:91]
#32 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#33 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#34 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#35 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->___callPlugins() called at [generated/code/Dealer4Dealer/SubstituteOrders/Controller/Order/Reorder/Interceptor.php:26]
#36 Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:159]
#37 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:99]
#38 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#39 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#40 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#41 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#42 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#43 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#44 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#45 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#46 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:137]
#47 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#48 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#49 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]
davekleijn commented 4 years ago

@Timothy-V I also got that error when trying to add a try catch block. Looks like that is caused by $this->cart->save(); in \Dealer4Dealer\SubstituteOrders\Controller\Order\Reorder::reorderByOrderItems. But I don't know why.