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

How to Provide BOGO (Buy One Get One) Offers for WooCommerce Products with Low Sales count?

If you have products in your online store that have very low sales counts and have been sitting stagnant for a long time, then this customization is incredibly valuable. By coupling these products with Buy One Get One offers, you not only clear out slow-moving inventory but also create space for seasonal or new arrivals. This proactive approach minimizes the risk of selling outdated or out-of-season items, keeping your store fresh and appealing to customers looking for great deals.

Provide BOGO (Buy One Get One) Offers for WooCommerce Products with Low Sales count

This code will offer a free product when a product with a low sales count (threshold set to 5) is added to the cart.

function ts_offer_free_product_based_on_sales_count( $item_key, $product_id ) {
    // Define the threshold for low sales count
    $low_sales_threshold = 5;

    // Get the sales count for the product
    $sales_count = get_post_meta( $product_id, 'total_sales', true );

    // Check if the product has a low sales count
    if ( $sales_count && $sales_count <= $low_sales_threshold ) {
        $free_product_id = 470; // Product Id of the free product which will get added to cart

        // Check if the free product is not already in the cart
        $found = false;
        foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
            $_product = $values['data'];
            if ( $_product->get_id() == $free_product_id ) {
                $found = true;
                break;
            }
        }

        // If the free product is not found, add it to the cart
        if ( ! $found ) {
            WC()->cart->add_to_cart( $free_product_id );
        }
    }
}

// Hook to add free product based on sales count
add_action( 'woocommerce_add_to_cart', 'ts_offer_free_product_based_on_sales_count', 10, 2 );
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

Let’s find out how the total sales of a product is determined for a product from the backend.

How to Provide BOGO (Buy One Get One) Offers for WooCommerce Products with Low Sales count? - Tyche Softwares

As the total sales count of the above product is less than the threshold set in the code ($low_sales_threshold = 5), the free product is added automatically whenever this product is added to the cart.

BOGO (Buy One Get One) Offers for WooCommerce Products

Moreover, exploring additional methods to implement BOGO strategies with high-rated products in WooCommerce can effectively promote items that have received positive feedback from customers.

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