Do you want to provide a BOGO (Buy One Get One) offer to your users based on their order total? If so, this WooCommerce customization can help incentivize customers to spend more than they originally intended.
During peak shopping seasons, such as Black Friday or holiday sales, when customers are already inclined to spend more, strategically setting these BOGO offers will encourage them to reach the minimum purchase amount to receive a free product. Let’s explore how this WooCommerce snippet can increase your store’s profitability.
Solution: Set Up BOGO (Buy One Get One) Offer Based on Order Total in WooCommerce
This code snippet will check the order total and if it meets the threshold amount set in the code, then the free product gets added to the cart.
add_action('template_redirect', 'ts_add_product_to_cart'); function ts_add_product_to_cart() { if (!is_admin()) { global $woocommerce; $product_id = 470; // Replace with your product id $found = false; $order_total = 200; // Replace with your order total needed to add the above item if ($woocommerce->cart->total >= $order_total) { // Check if the product is already in the cart if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) { $_product = $values['data']; if ($_product->get_id() == $product_id) { $found = true; } } // If product not found, add it if (!$found) { $woocommerce->cart->add_to_cart($product_id); } } else { // If no products in cart, add it $woocommerce->cart->add_to_cart($product_id); } } } }
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
The below output shows that when the cart total is greater than the threshold amount set in the code ( $order_total = 200), then the free gift is automatically added to the cart.
When the order total is below the threshold amount, the free product doesn’t get added to the cart.
Alternatively, you can also provide BOGO offers on different conditions. Explore a variety of promotional strategies, such as automatically adding a product to your cart under different conditions like specific categories, cart totals, or even on website visits.