How to Add WooCommerce Storefront Quantity Discount

Storefront Quantity DiscountDo you want to offer quantity based discounts in your WooCommerce store? Offering price or percentage discounts based on quantity purchased is a popular trend in most online stores. WooCommerce does not have the built-in functionality to do this. Stick to the end, and I will show you how. For example, you might want users to get a 10 % discount if they buy five items.

There are many reasons why you may want to offer a quantity-based discount offer in your store. You could use this strategy to clear your stocks in a faster phase. Additionally, you can use it as a marketing strategy to campaign your store, to grow your sales and revenue.

Discount price by quantity is one of the best dynamic pricing strategies. It is an effective way of encouraging customers to purchase more quantities of products at a discounted rate. In other words, you are providing quantity discounts and tiered pricing based on purchases made by the customers or bulk discounts based on quantities.

Benefits of Quantity Based Discounts

WooCommerce quantity-based discounts help you to move your goods and your customers to purchase at lower rates. These discounts great when you want to move your inventory. You can use it in a clearance sale or end of season sale.

Moreover, it encourages customers to purchase in larger quantities as the cost per unit is decreased. This, in turn, brings more sales to your WooCommerce store.

Steps to Add a Quantity Discount in the WooCommerce Storefront Theme

For this feature to be successful, you need to assign different unit prices based on Cart’s quantity. For example, from 1-100 price is $7, from 101-1000 price is $8.90 and from 1001 units ordered price becomes $9.75.price for shirt

In the image above, the product price is $19. I want to offer a 5% discount above 100 units and a 10% discount for more than 1000 units.

Here are the steps that you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add a quantity discount in the WooCommerce Storefront theme.
  3. Add the following code to the functions.php file:
/**

 *        Bulk or Dynamic Pricing

*/

add_action( 'woocommerce_before_calculate_totals', 'njengah_quantity_based_pricing', 9999 );

function njengah_quantity_based_pricing( $cart ) {

    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;

    // Define discount rules and thresholds

    $threshold1 = 101; // Change price if items > 100

    $discount1 = 0.05; // Reduce unit price by 5%

    $threshold2 = 1001; // Change price if items > 1000

    $discount2 = 0.1; // Reduce unit price by 10%

    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {

      if ( $cart_item['quantity'] >= $threshold1 && $cart_item['quantity'] < $threshold2 ) {

         $price = round( $cart_item['data']->get_price() * ( 1 - $discount1 ), 2 );

         $cart_item['data']->set_price( $price );

      } elseif ( $cart_item['quantity'] >= $threshold2 ) {

         $price = round( $cart_item['data']->get_price() * ( 1 - $discount2 ), 2 );

         $cart_item['data']->set_price( $price );

      }   

    }

    }

This is the outcome for a 5% discount above 100 units:Quantity based discount

This is the outcome for a 10% discount above 1000 units:Quantity based discount 2

Conclusion

In summary, I have shared the benefits of adding quantity-based discounts on your WooCommerce store. Remember to place the PHP snippet at the bottom of your child theme functions.php file. You can use this strategy to generate sales as it encourages customers to purchase in larger quantities as the cost per unit is decreased.

Similar Articles