I want to apply the discount on every $X spent amount. For example,

  • if $5 discount for every $10,
  • and my cart total is $34 then,
  • I will get the discount of $15.

Is it possible by programmatically in magento 2?


Hey there are two ways to do it

1.you can create a rule for this in which you need to define that if you added a product of 10$ then give 5$ off this is the easiest way to do it or you can give off in terms of how much percent you want to give off i recommend this approach to you.you can create cart rule from admin.

2.You have to manipulate the cart total by getting cart price from quote table and minus the discount you want lets say 5$ and set that total into quote table again. This is a bit long and complex to do it

I recommend to use cart price rule.

If you find this answer useful accept it as solution or give a upvote thanks.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.