How to change price based on Quantity added on cart page without plugin?

Photo of author
Written By geekerhub

Lorem ipsum dolor sit amet consectetur pulvinar ligula augue quis venenatis. 

If the client wants to vary price based on the number of quantity added to cart for specific products then as a developer we must ignore the use of the plugin and do necessary changes as per hooks and filters of the WooCommerce.

Rather than using a plugin, try to use the code snippet which will help in site speed and code security.

To apply such logic in WooCommerce is possible using hooks and the hook related to this snippet is “woocommerce_before_calculate_totals”

Let’s take an example:
The default price of the product is 50 USD.
The client wants to vary the price of the product if there are 50 quantity for the same product.
i.e client wants to add a discount for the product if the quantity is 50.

Leave a Comment