Skip to content
Advertisement

Automatically add a percentage discount if WooCommerce cart contains at least X products

I am trying to create an automated discount that kicks in when and if the cart contains a minimum of three products or more.

If and when that is, a discount of 10% should be given no matter if the customer is logged in or not.

This is the code I’m trying to get to work (without success).

JavaScript

Advertisement

Answer

It depends on whether you want to count the number of products in the cart or the number of product quantities (contents).

In my answer I have illustrated both, uncomment/delete/adjust to your needs.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement