Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Offer Store-wide Global Discount in WooCommerce?

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' );
flexi bogo cta banner image


This to the shop owners who are running or planning to run BOGO offers on their WooCommerce store…

BOGO deals are great for increasing your sales, but have you thought about which offers are bringing you more revenue and which offers are not performing that great?

Don’t just set a BOGO deal, track the revenue generated by your deals in real-time with the Flexi BOGO for WooCommerce plugin.

Output

Before seeing the output, let’s get a glance at the regular prices of the products that are discounted.

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.

Store-wide Global Discount

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.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x