WooCommerce : Dynamic Pricing According To Quantity.


WooCommerce : Dynamic Pricing According To Quantity.

How To Set Dynamic Pricing Of Product According To Quantity?.

Dynamic Pricing may be set by setting pricing rules based on products, order totals, roles, and product categories. In this post we will set price according to product quantity.

Dynamic Pricing According To Quantity Set By Two Condition”

Minimum Quantity: This is the Minimum Quantity of product that must be in the cart for the specific price rule.
Max Quantity: This is the Maximum Quantity of product that must be in the cart for the specific price rule.

WooCommerce price by quantity is one of the best dynamic pricing strategies to attract more buyers. It is an effective way of encouraging customers to purchase more quantities of products at a discounted rate.

You can provide label on product or on shop pages to show buyer , information about bulk discounts based on quantities.
Example:
Buy 1 to 5 and get 5% discount
Buy 5 to 9 and get 10% discount
Buy 10 to 15 and get 15% discount.
Buy 16 to 20 and get 20% discount.

this will attract user to buy more.

For this use 'woocommerce_before_calculate_totals' hook.

Example: Suppose we want product price according to quantity .

function QuantityBasedPricing( $cart ) {  
    if ( is_admin() && ! defined('DOING_AJAX') ) return;
    if ( did_action('woocommerce_before_calculate_totals') >= 2 ) return;
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
      if($cart_item['quantity']<6){
        $price = round( $cart_item['data']->get_price() * (1-  0.05 ), 2 );
        $cart_item['data']->set_price( $price );
      }   
      if($cart_item['quantity']>6 and $cart_item['quantity']<11){
        $price = round( $cart_item['data']->get_price() * (1-  0.10), 2 );
        $cart_item['data']->set_price( $price );
      }  
      if($cart_item['quantity']>10 and $cart_item['quantity']<16){
        $price = round( $cart_item['data']->get_price() * (1-  0.15), 2 );
        $cart_item['data']->set_price( $price );
      }  
      if($cart_item['quantity']>15){
        $price = round( $cart_item['data']->get_price() * (1-  0.20), 2 );
        $cart_item['data']->set_price( $price );
      }     
    }
}
add_filter('woocommerce_before_calculate_totals','QuantityBasedPricing');

Shiv kumawat

Executive Director & CEO

"Shiv kumawat is the Executive Director and CEO of Eoxys It Solution LLP and the strategic mind behind the company"s growth. His expertise in operational efficiency and team leadership empowers his colleagues to excel and innovate.”

Latest Posts

Factories of the Future: How AI is Powering a Manufacturing Revolution in the USA

  Factories of the Future: How AI is Powering a Manufacturing Revolution in the USA A New Era for American…

Shafeeq Khan
August 28, 2025

Reinventing Everyday Life: The Rise of Artificial Intelligence in Finance for 2025

  Reinventing Everyday Life: The Rise of Artificial Intelligence in Finance for 2025 A New Financial Landscape Artificial intelligence isnʼt…

Shafeeq Khan
August 14, 2025

AI in Retail USA Redefining Shopping, Operations, and Experiences in 2025

  AI in Retail USA: Redefining Shopping, Operations, and Experiences in 2025 How Artificial Intelligence Is Changing Retail in the…

Shafeeq Khan
August 11, 2025
, ,

Leave a Reply

Your email address will not be published. Required fields are marked *