Magento2.4.x coupon with uses per coupon 1 and per customer with coupon not working

By | June 5, 2023
Spread the love

How to solve magento 2 coupon issues? Please check below all steps. Currently default magento have bug.

Issue: Create a coupon with uses per coupon as 1 and uses per customer as 1 also. Even both uses type set to 1 even after that we are able to apply coupon multiple times and it shows success message.

Current Result: Applying same coupon with same customer is getting applied.

Expected Result: If uses per coupon and per customer set 1 than once order placed with coupon and again applying same coupon should give error.

Solution:

Add new observer in events.xml

<event name="sales_order_save_after">
    <observer name="sales_order_assign_customer_after" instance="Magento\SalesRule\Observer\AssignCouponDataAfterOrderCustomerAssignObserver" />
</event>