Store owners implement store-wide BOGO discounts mainly not just to increase sales. It’s a strategic move to drive traffic volume and create a compelling reason for shoppers to explore your store, find great deals, and return for more. Let’s dive into how to offer store-wide discounts which can be a game-changer for your business.
Solution: Offer Store-wide Global Discount in WooCommerce
The code snippet provided below offers a storewide 25% discount applied to all products within a store. The discount is applied on the cart page, modifying regular prices to discounted prices.
function ts_apply_discount_to_all_products( $cart ) { // Apply a 25% discount all the time foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) { // Get the product object $product = $cart_item['data']; // Calculate the 25% discount $discount_percentage = 0.25; $regular_price = $product->get_regular_price(); $discounted_price = $regular_price - ( $regular_price * $discount_percentage ); // Set the discounted price $product->set_price( $discounted_price ); } } // Hook to apply the discount to all products add_action( 'woocommerce_before_calculate_totals', 'ts_apply_discount_to_all_products' );
Output
Before seeing the output, let’s get a glance at the regular prices of the products that are discounted.
![How to Offer Store-wide Global Discount in WooCommerce? 1 How to Offer Store-wide Global Discount in WooCommerce? - Tyche Softwares](https://media.tychesoftwares.com/wp-content/uploads/regular-prices-of-products-1024x619.png)
When customers add the products to the cart, the code calculates the discount using the regular price and the discounted price is displayed on the cart page as shown below.
![How to Offer Store-wide Global Discount in WooCommerce? 2 How to Offer Store-wide Global Discount in WooCommerce? - Tyche Softwares](https://media.tychesoftwares.com/wp-content/uploads/25-Storewide-discount-to-all-products-1024x475.png)
While offering store wide discounts is an effective strategy to attract more customers, you can also focus on targeted promotions. In targeted promotions, you can create bogo but one get one offers based on product ids in WooCommerce and draw customers’ attention to particular products that the store wants to sell soon.