Setting a promotion for a limited time or a seasonal sale creates a sense of urgency, encouraging customers to act quickly to take advantage of the “Buy One Get One” offer. For example, if you run this WooCommerce promotion during the week leading up to Christmas, it can significantly boost your sales. Customers will appreciate the extra value they receive during the holiday season, enhancing their overall shopping experience.
Solution: Set a Scheduled BOGO (Buy One Get One) Offer in WooCommerce
The code checks the order date against the defined start and end date, and if the order falls within the specified date range, the free gift is added to the customer’s cart during the checkout process.
function ts_schedule_periodic_discount_with_free_gift($cart) { // Define the start and end dates for the promotion $start_date = strtotime('2024-01-10'); // Replace with your start date $end_date = strtotime('2024-02-25'); // Replace with your end date // Get the current date $current_date = current_time('timestamp'); // Check if the current date is within the promotion period if ($current_date >= $start_date && $current_date <= $end_date) { // Set the product ID for the free gift $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)); // Display a custom notice (optional) wc_clear_notices(); wc_add_notice(__('Limited Time Offer! Free gift added to your cart.'), 'notice'); } } } // Hook the function to the woocommerce_cart_calculate_fees action add_action('woocommerce_cart_calculate_fees', 'ts_schedule_periodic_discount_with_free_gift', 10, 1);
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
If a customer places an order within the specified time frame set in the code (between the start and end dates), they will receive a complimentary gift along with their purchase that gets added to the cart items.
Don’t limit your promotions to just specific dates! Instead, take advantage of time-sensitive offers and add BOGO buy one get one offers based on time limits in WooCommerce.