Skip to content

Magento 2 apply coupon code or 20% discount after order already placed

We have cod orders in site. But we are giving discount to customers who have paid early payment using razorpay link.

I want to apply coupon code test123 from cart rule. Where we didn’t set any actions or condition in admin for this rule.
After order placed, in order view page in admin, we have created text field.

In text box, our representative talks with customer and apply coupon code in text box which generates payment link.
We have created controller which validates if coupon code is valid.
If it is valid we have generated razorpay payment link for payment.
Once payment is made,
Here we want to set discount based on the coupon code to perticular order.

E.g if coupon rule has description with 20% text so we are fetching 20% and need to apply calculation on cod order.