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

How to Set Up Buy Two Get One Free (BOGO) Offer in WooCommerce?

Are you looking to encourage bulk purchases with the BOGO “Buy Two Get one free” offers in your WooCommerce store? These BOGO deals encourage customers to purchase more items to get the free product, which can significantly increase your overall sales volume.

For instance, a customer buying two products to receive a third for free might spend more than they initially intended, leading to higher revenue. This strategy effectively increases revenue without requiring more customers to visit your store.

Solution: Set Up Buy Two Get One Free (BOGO) Offer in WooCommerce

The below snippet adds a “Buy 2 Get 1 Free” offer to attract shoppers to specific products. This applies a free item for every two purchased items of targeted products.

add_action('woocommerce_cart_calculate_fees', 'ts_buy_two_get_one_free', 10, 1 );

function ts_buy_two_get_one_free( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

    // Set your targeted free product IDs
    $targeted_product_ids = array(34);

    $each_n_items = 2; // Number of items required to get a free one
    $discount = 0; // Initializing

    foreach ( $cart->get_cart() as $cart_item ) {
        if ( in_array( $cart_item['product_id'], $targeted_product_ids ) ) {
            $qty = intval( $cart_item['quantity'] );

            // Calculate discount based on the number of items
            $free_items = floor( $qty / ($each_n_items + 1) );
            $discount += $free_items * floatval( $cart_item['data']->get_price() );
        }
    }

    if ( $discount > 0 ) {
        // Displaying a custom notice (optional)
        wc_clear_notices();
        wc_add_notice( __("Congratulations! You've earned a free item for every 2 purchased items."), 'success');

        // Apply the discount
        $cart->add_fee( __("Buy 2 Get 1 Free"), -$discount, true );
    }
}
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

When a customer adds three of the same items, they will receive one item for free. The discount will be automatically applied to the cart totals section of the WooCommerce cart page as shown below.

How to Implement Buy Two Get One for Free Offer in WooCommerce Cart?

Explore similar discount strategies such as offering bulk quantity discount (Buy 10 Get 1 Free) in WooCommerce which will make customers buy items in bulk quantities and boosts the average order value. If you have any specific requirements, feel free to mention it in the comment section!

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