MultiSafepay / magento2

MultiSafepay plugin for Magento 2
Open Software License 3.0
19 stars 8 forks source link

Coupon cancel recovery fix #66

Open BartHuisHorizon opened 2 weeks ago

BartHuisHorizon commented 2 weeks ago

We have a bug that we have encounter at 2 of our customers where the same fix had to be aplied. It's about coupons not being returned to there original value once a order has bin canceled. And that they are counted as being used even when the order is canceled.

To Reproduce Steps to reproduce the behavior: 1: Make a Coupon single code, single use. 2: Order a product and go to Cart. 3: go to payment and than go to when you can add the coupon code. 4: do a testpayment and cancel the order.

Expected behavior Once the payment has bin canceled and return to the cart the coupon code should be able to aplied again.

Desktop (please complete the following information): We are on magento version 2.4.7

Additional context and Fix we apllied. The issue is in module-sales-rule/Model/Coupon/UpdateCouponUsages.php Line 50 public function execute(OrderInterface doesn't get triggered by the multisafe pay

We noticed that in module-sales-rule/etc/di.xml line 192 we noticed that

<type name="Magento\Sales\Model\Service\OrderService">
        <plugin name="coupon_uses_decrement_plugin" type="Magento\SalesRule\Plugin\CouponUsagesDecrement" />
    </type>

because Magento\Sales\Model\Service\OrderService = OrderService and not OrderInterface this does noet activated the: UpdateCouponUsages.php and leaves the coupon counted as used. Triggering this function fixes the issue.

we fixed by making a new plugin that hooks onto that OrderInterface.

    <type name="Magento\Sales\Api\Data\OrderInterface">
        <plugin name="<--nameCustomer-->_CouponUsageDecrement_Plugin_Magento_Sales_Api_Data_OrderInterface" type="<--nameCustomer-->\CouponUsageDecrement\Plugin\Magento\Sales\Api\Data\OrderInterface" sortOrder="10" disabled="false"/>
    </type>
</config>

I hope this wil be enaf info to fix the issue. Sincerly

danielcivit commented 2 weeks ago

Hi @BartHuisHorizon

Thanks for your report.

We will investigate this issue following your comments.

In any case, I would like to confirm that you are using the latest version of our module because we recently fixed an issue after receive a similar report, in 3.3.0

BartHuisHorizon commented 1 day ago

Hi danielcivit,

I can hereby confirme that in one of our shops were the same issue applies. We are on version 3.4.0 even when were one head this stil presist.