-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel order and restore quote methods increase stocks twice #9969
Comments
you found it, you patched it |
@simpleadm, Thanks for reporting this issue. |
Would it not work to just check in $order = $observer->getEvent()->getOrder();
if($order->getState() == \Magento\Sales\Model\Order::STATE_CANCELED){
// Clear flag, so if order placement retried again with success - it will be processed
$quote->setInventoryProcessed(false);
return;
} |
@ttraskback it should work. Currently will be better to add following plugin: di.xml <type name="Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver">
<plugin name="CatalogInventoryPlugin::RevertQuoteInventoryObserver" type="VendorName\ModuleName\Plugin\CatalogInventory\RevertQuoteInventoryObserver" sortOrder="100" />
</type> RevertQuoteInventoryObserver.php /**
* Skip revert products sale for canceled orders
*
* @param \Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver $subject
* @param \Closure $proceed
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @see \Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver::execute
*/
public function aroundExecute(
\Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver $subject,
\Closure $proceed,
\Magento\Framework\Event\Observer $observer
) {
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getOrder();
if ($order && $order->isCanceled()) {
return;
}
$proceed($observer);
} |
Hi @simpleadm, |
@simpleadm, thank you for your report. |
For anyone interested: #12668 (comment) |
…ts can now choose to not restore the cart, avoiding any stock issues because magento processes stock not correctly (magento/magento2#9969)
Hi @simpleadm. Thank you for your report. The fix will be available with the upcoming patch release. |
Hi @simpleadm. Thank you for your report. The fix will be available with the upcoming patch release. |
Hi @simpleadm. Thank you for your report. The fix will be available with the upcoming patch release. |
…o master * commit '80491c0ac1e1fd3e9efe01b71eecdec5e1e4ccee': PLGMAGTWOS-227 - Updated version to 1.4.8 PLGMAGTWOS-226 - Processed codeformatting tool PLGMAGTWOS-221. Custom "pending" state can now be used. PLGMAGTWOS-205. Added an option to reset the payment method for when a payment link was created when an order was added through the Magento backend. PLGMAGTWOS-220. Added BTW0 alternate tax rule for FPT PLGMAGTWOS-220. FPT are now processed within the transaction request. PLGMAGTWOS-219. Keep cart alive function is now configurable. Merchants can now choose to not restore the cart, avoiding any stock issues because magento processes stock not correctly (magento/magento2#9969) PLGMAGTWOS-223, fixes Id required error when creating an order from the backend i.c.m. a MultiSafepay payment method.
Some payment methods in cancel payment action try to cancel current order and restore quote and as the result product qty is increased by 2.
Affected payment methods
Preconditions
Steps to reproduce
Expected result
Actual result
Additional information
For example Paypal Hosted Pro Cancel action
\Magento\Paypal\Controller\Hostedpro\Cancel
Method
cancelCurrentOrder
will execute$order->registerCancellation($comment)->save();
that will cancel all order items and dispatch 'sales_order_item_cancel' event for each one.\Magento\CatalogInventory\Observer\CancelOrderItemObserver
observer listens this event and increases product qty.Next
\Magento\Checkout\Model\Session::restoreQuote()
will be executed to restore customer quote. That method will update and save a quote and dispatchrestore_quote
event.\Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver
listens to this event and product qty is increased the second time.The problem is that both statements increase quantity of product.
The same issue in Payflow cancel action
\Magento\Paypal\Controller\Payflow
:The text was updated successfully, but these errors were encountered: