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

How to Add BOGO (Buy One Get One) Offer Based on Cart Weight in WooCommerce?

Adding a WooCommerce BOGO (Buy One Get One) offer based on cart weight can be particularly beneficial for stores that sell products where quantity and weight play crucial roles. With such WooCommerce customization, you can entice customers to return to the store by offering discounts based on the cumulative weight of their purchases. Let’s dive in to know the implementation steps!

Solution: Add BOGO (Buy One Get One) Offer Based on Cart Weight in WooCommerce

The code will calculate the total cart weight and if the cart weight reaches the threshold weight as specified in the code, the complimentary gift is offered.

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

function ts_add_free_gift_based_on_cart_weight($cart) {
    // Set the weight threshold for the free gift
    $weight_threshold = 10; // Adjust this value to your specific requirement

    // Get the total cart weight
    $cart_weight = $cart->cart_contents_weight;

    // Check if the cart weight is greater than or equal to the threshold
    if ($cart_weight >= $weight_threshold) {
        // Set the free gift product ID
        $free_gift_product_id = 470; // Change this to your actual free gift product ID

        // Check if the free gift is not already in the cart
        if (!in_array($free_gift_product_id, array_column($cart->get_cart(), 'product_id'))) {
            // Add the free gift to the cart
            $cart->add_to_cart($free_gift_product_id, 1, 0, array(), array('free_gift' => true));

            // Displaying a custom notice (optional)
            wc_clear_notices();
            wc_add_notice(__('Free gift added to your cart based on weight!'), 'notice');
        }
    }
}
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 the customer adds the product to the cart, the cart loops through each product in the cart and adds the product weight to the total cart weight if available. When the total weight of the cart reaches the specified threshold amount, the free product is added in such a scenario.

The following output shows that even if there is only 1 item in the cart and when the product count is incremented, it calculates the total cart weight based on the quantity and adds the free product accordingly.

setting up BOGO offers based on cart weight in WooCommerce

Similarly, expand your promotions to add bogo buy one get one offer based on individual product weight in WooCommerce.This customization can attract customers looking for deals on particular items.

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