The code snippet below allows you to:
- Show a notice on the cart and checkout page, reminding customers that they get a discount if spending more than a minimum amount.
- Automatically apply a discount and show a notice that the discount was applied when the cart total is more than a minimum amount.
First make sure you have enabled coupons in the settings. Then go to Commerce -> Coupons and create a coupon called COUPON. The coupon type is “percentage discount” and the “coupon amount” is 25. The minimum spending amount is set in the code below as 100.