Why do we need to target guest users with BOGO offers? This is because guest users are among the list of your potential customers who covers a wider audience. By enticing these visitors with irresistible BOGO deals, you can incentivize them to make a purchase and create an account on your website.
Let’s dive into the step-by-step process to add this customization to your WooCommerce store.
Solution: Add BOGO (Buy One Get One) Offers for Guest Users in WooCommerce
This code snippet adds the free product to the cart only for non-logged-in/guest users enticing these visitors to engage further. The free product is not added for users of any other user roles.
// Add a free gift for guest users add_action('woocommerce_before_calculate_totals', 'ts_add_free_gift_for_guests'); function ts_add_free_gift_for_guests($cart) { if (is_admin() && !defined('DOING_AJAX')) { return; } // Check if the user is a guest if (!is_user_logged_in()) { // Get the free gift product ID $free_gift_product_id = 470; // Change this to the actual product ID of your free gift // Check if the free gift is not already in the cart $free_gift_in_cart = false; foreach ($cart->get_cart() as $cart_item) { if ($cart_item['product_id'] == $free_gift_product_id) { $free_gift_in_cart = true; break; } } // If the free gift is not in the cart, add it if (!$free_gift_in_cart) { $cart->add_to_cart($free_gift_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
When a non-logged-in user visits your website and adds a product to the cart, the corresponding free product, as defined in the code, is also automatically added to the cart.
A user who is not logged-in need not always be a first-time website visitor. You can also use such BOGO strategies and attract new customers by creating buy one get one offer for first time website visitors in WooCommerce. Let us know how the code was useful or any other queries in the comments.