Magento 2 Restore Quote/Cart after order is cancelled/Failed












4














I am Trying to Restore Quote/Cart after order is cancelled/Failed in custom payment gateway (CCAvenue) but the problem it the quantity of item restored is doubled.



protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}


in above code $this->_checkoutHelper->cancelCurrentOrder($errorMsg); is use to cancel last real order and $this->_checkoutSession->restoreQuote() is use to restore the cart but the problem is both the statements increase quantity of product.



Eg.




  • suppose I have Product XYZ with stock quantity: 1


  • When I add product to cart and Checkout The order is placed and stock is reduced to 0.


  • but when I click cancel on Payment gateway I return Back to my site and the above method is called.

  • And now the stock increase to 2 because $this->_checkoutHelper->cancelCurrentOrder($errorMsg); and $this->_checkoutSession->restoreQuote() increase the quantity of the product.


Is there any way to do both cancel order and restore quote while restore stock only once.



Edit: Complete Controller File.



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCcavenuepayController;
use MagentoCcavenuepayHelperData;
/**
* Payflow Checkout Controller
*/
abstract class Ccavenuepay extends MagentoFrameworkAppActionAction
{
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;
protected $logger;

/**
* @var MagentoCcavenuepayModelCcavenuepay
*/
protected $_ccavenuepay;

/**
* @var MagentoCcavenuepayHelperCheckout
*/
protected $_checkoutHelper;

/**
* @var MagentoCcavenuepayHelperdata
*/
protected $_ccavenuepayHelper;

/**
* Redirect block name
* @var string
*/
protected $_redirectBlockName = 'ccavenuepay.iframe';

/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoSalesModelOrderFactory $orderFactory
* @param MagentoCcavenuepayModelPayflowlinkFactory $ccavenuepay
* @param MagentoCcavenuepayHelperCheckout $checkoutHelper
* @param PsrLogLoggerInterface $logger
*/



public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderFactory $orderFactory,
MagentoCcavenuepayModelCcavenuepay $ccavenuepay,
MagentoCcavenuepayHelperCheckout $checkoutHelper,
PsrLogLoggerInterface $logger
) {

$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$this->logger = new ZendLogLogger();
$this->logger->addWriter($writer);
$this->logger->info("__construct=====Ccavenuepay extends MagentoFrameworkAppActionAction");


$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->_logger = $logger;
$this->_ccavenuepay = $ccavenuepay;
$this->_checkoutHelper = $checkoutHelper;
//$this->_ccavenuepayHelper = $this->_ccavenuepay;
parent::__construct($context);
}




/**
* Cancel order, return quote to customer
*
* @param string $errorMsg
* @return false|string
*/
protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}

public function errorAction()
{
$this->_redirect('checkout/onepage/');
}

//check_module_upload
//newmoduleupdate_now
/**
* Check if email is registered at Moneybookers
*/



protected function _getCheckout()
{
return $this->_objectManager->get('MagentoCheckoutModelSession');
}
/**
* Get session model
*
* @return MagentoCcavenuepayModelCcavenuepaySession
*/
protected function _getCcavenuepayPostSession()
{
return $this->_objectManager->get('MagentoCcavenuepayModelCcavenuepaySession');
}
protected function _getHelper()
{
return $this->_ccavenuepay->getHelper();
}
}









share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Can you write more detail about restoreQuote and cancelCurrentOrder?
    – Sohel Rana
    Nov 21 '16 at 15:09










  • @SohelRana I have updated question
    – Arun Karnawat
    Nov 22 '16 at 5:29






  • 2




    Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
    – Hardik
    May 12 '17 at 6:08
















4














I am Trying to Restore Quote/Cart after order is cancelled/Failed in custom payment gateway (CCAvenue) but the problem it the quantity of item restored is doubled.



protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}


in above code $this->_checkoutHelper->cancelCurrentOrder($errorMsg); is use to cancel last real order and $this->_checkoutSession->restoreQuote() is use to restore the cart but the problem is both the statements increase quantity of product.



Eg.




  • suppose I have Product XYZ with stock quantity: 1


  • When I add product to cart and Checkout The order is placed and stock is reduced to 0.


  • but when I click cancel on Payment gateway I return Back to my site and the above method is called.

  • And now the stock increase to 2 because $this->_checkoutHelper->cancelCurrentOrder($errorMsg); and $this->_checkoutSession->restoreQuote() increase the quantity of the product.


Is there any way to do both cancel order and restore quote while restore stock only once.



Edit: Complete Controller File.



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCcavenuepayController;
use MagentoCcavenuepayHelperData;
/**
* Payflow Checkout Controller
*/
abstract class Ccavenuepay extends MagentoFrameworkAppActionAction
{
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;
protected $logger;

/**
* @var MagentoCcavenuepayModelCcavenuepay
*/
protected $_ccavenuepay;

/**
* @var MagentoCcavenuepayHelperCheckout
*/
protected $_checkoutHelper;

/**
* @var MagentoCcavenuepayHelperdata
*/
protected $_ccavenuepayHelper;

/**
* Redirect block name
* @var string
*/
protected $_redirectBlockName = 'ccavenuepay.iframe';

/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoSalesModelOrderFactory $orderFactory
* @param MagentoCcavenuepayModelPayflowlinkFactory $ccavenuepay
* @param MagentoCcavenuepayHelperCheckout $checkoutHelper
* @param PsrLogLoggerInterface $logger
*/



public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderFactory $orderFactory,
MagentoCcavenuepayModelCcavenuepay $ccavenuepay,
MagentoCcavenuepayHelperCheckout $checkoutHelper,
PsrLogLoggerInterface $logger
) {

$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$this->logger = new ZendLogLogger();
$this->logger->addWriter($writer);
$this->logger->info("__construct=====Ccavenuepay extends MagentoFrameworkAppActionAction");


$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->_logger = $logger;
$this->_ccavenuepay = $ccavenuepay;
$this->_checkoutHelper = $checkoutHelper;
//$this->_ccavenuepayHelper = $this->_ccavenuepay;
parent::__construct($context);
}




/**
* Cancel order, return quote to customer
*
* @param string $errorMsg
* @return false|string
*/
protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}

public function errorAction()
{
$this->_redirect('checkout/onepage/');
}

//check_module_upload
//newmoduleupdate_now
/**
* Check if email is registered at Moneybookers
*/



protected function _getCheckout()
{
return $this->_objectManager->get('MagentoCheckoutModelSession');
}
/**
* Get session model
*
* @return MagentoCcavenuepayModelCcavenuepaySession
*/
protected function _getCcavenuepayPostSession()
{
return $this->_objectManager->get('MagentoCcavenuepayModelCcavenuepaySession');
}
protected function _getHelper()
{
return $this->_ccavenuepay->getHelper();
}
}









share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Can you write more detail about restoreQuote and cancelCurrentOrder?
    – Sohel Rana
    Nov 21 '16 at 15:09










  • @SohelRana I have updated question
    – Arun Karnawat
    Nov 22 '16 at 5:29






  • 2




    Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
    – Hardik
    May 12 '17 at 6:08














4












4








4


3





I am Trying to Restore Quote/Cart after order is cancelled/Failed in custom payment gateway (CCAvenue) but the problem it the quantity of item restored is doubled.



protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}


in above code $this->_checkoutHelper->cancelCurrentOrder($errorMsg); is use to cancel last real order and $this->_checkoutSession->restoreQuote() is use to restore the cart but the problem is both the statements increase quantity of product.



Eg.




  • suppose I have Product XYZ with stock quantity: 1


  • When I add product to cart and Checkout The order is placed and stock is reduced to 0.


  • but when I click cancel on Payment gateway I return Back to my site and the above method is called.

  • And now the stock increase to 2 because $this->_checkoutHelper->cancelCurrentOrder($errorMsg); and $this->_checkoutSession->restoreQuote() increase the quantity of the product.


Is there any way to do both cancel order and restore quote while restore stock only once.



Edit: Complete Controller File.



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCcavenuepayController;
use MagentoCcavenuepayHelperData;
/**
* Payflow Checkout Controller
*/
abstract class Ccavenuepay extends MagentoFrameworkAppActionAction
{
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;
protected $logger;

/**
* @var MagentoCcavenuepayModelCcavenuepay
*/
protected $_ccavenuepay;

/**
* @var MagentoCcavenuepayHelperCheckout
*/
protected $_checkoutHelper;

/**
* @var MagentoCcavenuepayHelperdata
*/
protected $_ccavenuepayHelper;

/**
* Redirect block name
* @var string
*/
protected $_redirectBlockName = 'ccavenuepay.iframe';

/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoSalesModelOrderFactory $orderFactory
* @param MagentoCcavenuepayModelPayflowlinkFactory $ccavenuepay
* @param MagentoCcavenuepayHelperCheckout $checkoutHelper
* @param PsrLogLoggerInterface $logger
*/



public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderFactory $orderFactory,
MagentoCcavenuepayModelCcavenuepay $ccavenuepay,
MagentoCcavenuepayHelperCheckout $checkoutHelper,
PsrLogLoggerInterface $logger
) {

$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$this->logger = new ZendLogLogger();
$this->logger->addWriter($writer);
$this->logger->info("__construct=====Ccavenuepay extends MagentoFrameworkAppActionAction");


$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->_logger = $logger;
$this->_ccavenuepay = $ccavenuepay;
$this->_checkoutHelper = $checkoutHelper;
//$this->_ccavenuepayHelper = $this->_ccavenuepay;
parent::__construct($context);
}




/**
* Cancel order, return quote to customer
*
* @param string $errorMsg
* @return false|string
*/
protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}

public function errorAction()
{
$this->_redirect('checkout/onepage/');
}

//check_module_upload
//newmoduleupdate_now
/**
* Check if email is registered at Moneybookers
*/



protected function _getCheckout()
{
return $this->_objectManager->get('MagentoCheckoutModelSession');
}
/**
* Get session model
*
* @return MagentoCcavenuepayModelCcavenuepaySession
*/
protected function _getCcavenuepayPostSession()
{
return $this->_objectManager->get('MagentoCcavenuepayModelCcavenuepaySession');
}
protected function _getHelper()
{
return $this->_ccavenuepay->getHelper();
}
}









share|improve this question















I am Trying to Restore Quote/Cart after order is cancelled/Failed in custom payment gateway (CCAvenue) but the problem it the quantity of item restored is doubled.



protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}


in above code $this->_checkoutHelper->cancelCurrentOrder($errorMsg); is use to cancel last real order and $this->_checkoutSession->restoreQuote() is use to restore the cart but the problem is both the statements increase quantity of product.



Eg.




  • suppose I have Product XYZ with stock quantity: 1


  • When I add product to cart and Checkout The order is placed and stock is reduced to 0.


  • but when I click cancel on Payment gateway I return Back to my site and the above method is called.

  • And now the stock increase to 2 because $this->_checkoutHelper->cancelCurrentOrder($errorMsg); and $this->_checkoutSession->restoreQuote() increase the quantity of the product.


Is there any way to do both cancel order and restore quote while restore stock only once.



Edit: Complete Controller File.



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCcavenuepayController;
use MagentoCcavenuepayHelperData;
/**
* Payflow Checkout Controller
*/
abstract class Ccavenuepay extends MagentoFrameworkAppActionAction
{
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;
protected $logger;

/**
* @var MagentoCcavenuepayModelCcavenuepay
*/
protected $_ccavenuepay;

/**
* @var MagentoCcavenuepayHelperCheckout
*/
protected $_checkoutHelper;

/**
* @var MagentoCcavenuepayHelperdata
*/
protected $_ccavenuepayHelper;

/**
* Redirect block name
* @var string
*/
protected $_redirectBlockName = 'ccavenuepay.iframe';

/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoCheckoutModelSession $checkoutSession
* @param MagentoSalesModelOrderFactory $orderFactory
* @param MagentoCcavenuepayModelPayflowlinkFactory $ccavenuepay
* @param MagentoCcavenuepayHelperCheckout $checkoutHelper
* @param PsrLogLoggerInterface $logger
*/



public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderFactory $orderFactory,
MagentoCcavenuepayModelCcavenuepay $ccavenuepay,
MagentoCcavenuepayHelperCheckout $checkoutHelper,
PsrLogLoggerInterface $logger
) {

$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$this->logger = new ZendLogLogger();
$this->logger->addWriter($writer);
$this->logger->info("__construct=====Ccavenuepay extends MagentoFrameworkAppActionAction");


$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->_logger = $logger;
$this->_ccavenuepay = $ccavenuepay;
$this->_checkoutHelper = $checkoutHelper;
//$this->_ccavenuepayHelper = $this->_ccavenuepay;
parent::__construct($context);
}




/**
* Cancel order, return quote to customer
*
* @param string $errorMsg
* @return false|string
*/
protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));

$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
if ($this->_checkoutSession->restoreQuote()) {
//Redirect to payment step
$gotoSection = 'paymentMethod';
}

return $gotoSection;
}

public function errorAction()
{
$this->_redirect('checkout/onepage/');
}

//check_module_upload
//newmoduleupdate_now
/**
* Check if email is registered at Moneybookers
*/



protected function _getCheckout()
{
return $this->_objectManager->get('MagentoCheckoutModelSession');
}
/**
* Get session model
*
* @return MagentoCcavenuepayModelCcavenuepaySession
*/
protected function _getCcavenuepayPostSession()
{
return $this->_objectManager->get('MagentoCcavenuepayModelCcavenuepaySession');
}
protected function _getHelper()
{
return $this->_ccavenuepay->getHelper();
}
}






magento2 orders magento-2.1 quote






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '16 at 12:35

























asked Nov 21 '16 at 14:07









Arun Karnawat

1,31321641




1,31321641





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Can you write more detail about restoreQuote and cancelCurrentOrder?
    – Sohel Rana
    Nov 21 '16 at 15:09










  • @SohelRana I have updated question
    – Arun Karnawat
    Nov 22 '16 at 5:29






  • 2




    Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
    – Hardik
    May 12 '17 at 6:08


















  • Can you write more detail about restoreQuote and cancelCurrentOrder?
    – Sohel Rana
    Nov 21 '16 at 15:09










  • @SohelRana I have updated question
    – Arun Karnawat
    Nov 22 '16 at 5:29






  • 2




    Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
    – Hardik
    May 12 '17 at 6:08
















Can you write more detail about restoreQuote and cancelCurrentOrder?
– Sohel Rana
Nov 21 '16 at 15:09




Can you write more detail about restoreQuote and cancelCurrentOrder?
– Sohel Rana
Nov 21 '16 at 15:09












@SohelRana I have updated question
– Arun Karnawat
Nov 22 '16 at 5:29




@SohelRana I have updated question
– Arun Karnawat
Nov 22 '16 at 5:29




2




2




Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
– Hardik
May 12 '17 at 6:08




Hello Arun, can you please post your answer. As you said you got solution for this in your last comment. Thanks
– Hardik
May 12 '17 at 6:08










1 Answer
1






active

oldest

votes


















0














Iam experiencing the same issue.
In my store i've removed the inventory observer in the restore_quote event.



In: vendor/magento/module-catalog-inventory/etc/events.xml



Remove:



<event name="restore_quote">
<observer name="inventory" instance="MagentoCatalogInventoryObserverRevertQuoteInventoryObserver"/>
</event>


Now the stock only gets increased on canceling the order, not on restoring the quote.






share|improve this answer























  • thank you you help, but I have already got solution for this.
    – Arun Karnawat
    Jan 18 '17 at 12:25






  • 1




    Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
    – Andy Pieters
    Jan 18 '17 at 12:44











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146765%2fmagento-2-restore-quote-cart-after-order-is-cancelled-failed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Iam experiencing the same issue.
In my store i've removed the inventory observer in the restore_quote event.



In: vendor/magento/module-catalog-inventory/etc/events.xml



Remove:



<event name="restore_quote">
<observer name="inventory" instance="MagentoCatalogInventoryObserverRevertQuoteInventoryObserver"/>
</event>


Now the stock only gets increased on canceling the order, not on restoring the quote.






share|improve this answer























  • thank you you help, but I have already got solution for this.
    – Arun Karnawat
    Jan 18 '17 at 12:25






  • 1




    Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
    – Andy Pieters
    Jan 18 '17 at 12:44
















0














Iam experiencing the same issue.
In my store i've removed the inventory observer in the restore_quote event.



In: vendor/magento/module-catalog-inventory/etc/events.xml



Remove:



<event name="restore_quote">
<observer name="inventory" instance="MagentoCatalogInventoryObserverRevertQuoteInventoryObserver"/>
</event>


Now the stock only gets increased on canceling the order, not on restoring the quote.






share|improve this answer























  • thank you you help, but I have already got solution for this.
    – Arun Karnawat
    Jan 18 '17 at 12:25






  • 1




    Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
    – Andy Pieters
    Jan 18 '17 at 12:44














0












0








0






Iam experiencing the same issue.
In my store i've removed the inventory observer in the restore_quote event.



In: vendor/magento/module-catalog-inventory/etc/events.xml



Remove:



<event name="restore_quote">
<observer name="inventory" instance="MagentoCatalogInventoryObserverRevertQuoteInventoryObserver"/>
</event>


Now the stock only gets increased on canceling the order, not on restoring the quote.






share|improve this answer














Iam experiencing the same issue.
In my store i've removed the inventory observer in the restore_quote event.



In: vendor/magento/module-catalog-inventory/etc/events.xml



Remove:



<event name="restore_quote">
<observer name="inventory" instance="MagentoCatalogInventoryObserverRevertQuoteInventoryObserver"/>
</event>


Now the stock only gets increased on canceling the order, not on restoring the quote.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 18 '17 at 12:04









Amit Bera

57.2k1374170




57.2k1374170










answered Jan 18 '17 at 11:44









Andy Pieters

1




1












  • thank you you help, but I have already got solution for this.
    – Arun Karnawat
    Jan 18 '17 at 12:25






  • 1




    Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
    – Andy Pieters
    Jan 18 '17 at 12:44


















  • thank you you help, but I have already got solution for this.
    – Arun Karnawat
    Jan 18 '17 at 12:25






  • 1




    Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
    – Andy Pieters
    Jan 18 '17 at 12:44
















thank you you help, but I have already got solution for this.
– Arun Karnawat
Jan 18 '17 at 12:25




thank you you help, but I have already got solution for this.
– Arun Karnawat
Jan 18 '17 at 12:25




1




1




Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
– Andy Pieters
Jan 18 '17 at 12:44




Can you please post your solution? I know my solution isn't ideal, because it involves updating the core magento code
– Andy Pieters
Jan 18 '17 at 12:44


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146765%2fmagento-2-restore-quote-cart-after-order-is-cancelled-failed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1300-talet

1300-talet

Display a custom attribute below product name in the front-end Magento 1.9.3.8