diff --git a/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php b/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php
index 66a32f37eee2f..a38cc35136cfc 100644
--- a/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php
+++ b/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php
@@ -10,6 +10,7 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteManagement;
+use Magento\Sales\Api\Data\OrderInterface;
use Magento\SalesRule\Model\Coupon\Quote\UpdateCouponUsages;
/**
@@ -34,13 +35,14 @@ public function __construct(UpdateCouponUsages $updateCouponUsages)
* Increments number of coupon usages before placing order
*
* @param QuoteManagement $subject
+ * @param \Closure $proceed
* @param Quote $quote
* @param array $orderData
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @return OrderInterface|null
* @throws NoSuchEntityException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function beforeSubmit(QuoteManagement $subject, Quote $quote, $orderData = [])
+ public function aroundSubmit(QuoteManagement $subject, \Closure $proceed, Quote $quote, $orderData = [])
{
/* if coupon code has been canceled then need to notify the customer */
if (!$quote->getCouponCode() && $quote->dataHasChangedFor('coupon_code')) {
@@ -48,5 +50,11 @@ public function beforeSubmit(QuoteManagement $subject, Quote $quote, $orderData
}
$this->updateCouponUsages->execute($quote, true);
+ try {
+ return $proceed($quote, $orderData);
+ } catch (\Throwable $e) {
+ $this->updateCouponUsages->execute($quote, false);
+ throw $e;
+ }
}
}
diff --git a/vendor/magento/module-sales-rule/etc/events.xml b/vendor/magento/module-sales-rule/etc/events.xml
index 0c8335b0a6716..c55c37de71aac 100644
--- a/vendor/magento/module-sales-rule/etc/events.xml
+++ b/vendor/magento/module-sales-rule/etc/events.xml
@@ -39,7 +39,4 @@
-
-
-