I would like to have a conditional progressive discount based on number of items in cart. After you added 2 products to the cart, you get a discount. More products you add and more discount you get.
For example:
- 1 product – full price (No Discount)
- 2 products – full price with 5% discount of the combined price
- 3 products – full price with 10% discount of the combined price
- 4 products – full price with 15% discount of the combined price
- And so on …
I have search over internet without any success. When searching about discounts I just fall on WooCommerce coupon feature or I get some old wrong code…
Any idea? How can I do it?
Is it possible?
Thanks.
Yes its possible to use a trick, to achieve this. Normally for discounts on cart we use in WooCommerce coupons. Here coupons are not appropriated. I will use here a negative conditional fee, that becomes a discount.
The calculation:
— The item count is based on quantity by item and total of items in cart
— The percent is 0.05 (5%) and it grows with each additional item (as you asked)
— We use the discounted subtotal (to avoid adding multiple collapsing discounts made by coupons)
The code:
Code goes in function.php file of your active child theme. Tested and works.
References: