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 for a Specific Day of the Week in WooCommerce?

Setting up a BOGO (Buy One, Get One) offer for a specific weekday can really help your WooCommerce store, especially when sales are slow. Sales often drop mid-week, but a well-timed promotion can turn those slow days into busy ones. Imagine automatically applying a BOGO promotion every Monday to attract more customers. Let’s dive in to know how this easy setup can boost your sales and keep your store active, even on typically quiet days.

Add BOGO (Buy One, Get One) Offer for a Specific Day of the Week in WooCommerce

The code enables a BOGO (Buy One, Get One) offer by automatically adding a free product to the cart when a customer makes a purchase on Mondays as defined in the code as ((date(‘w’) == 1). Additionally, notices are displayed on product pages and during the checkout process to inform customers about the offer.

// Utility conditional function that checks if the day is Monday (returns boolean)
function ts_is_monday() {
    // Set Your shop time zone (http://php.net/manual/en/timezones.php)
    date_default_timezone_set('America/New_York');

    // If the current day is Monday, return true (else return false)
    return (date('w') == 1) ? true : false;
}

// Utility function (setting your free product ID)
function ts_get_free_product_id() {
    return 470; // Change this to the ID of your free product
}

// Enable BOGO offer on Mondays
add_filter('woocommerce_add_to_cart_validation', 'ts_enable_bogo_offer_on_mondays', 10, 3);
function ts_enable_bogo_offer_on_mondays($passed, $product_id, $quantity) {
    // Enable BOGO offer only on Monday
    if (ts_is_monday()) {
        // Check if the product is not the free product itself
        if ($product_id !== ts_get_free_product_id()) {
            // Add the free product to the cart with a quantity of one
            WC()->cart->add_to_cart(ts_get_free_product_id(), 1);
        }
    }

    return $passed;
}

// Add a notice for free product on product page
add_action('woocommerce_before_single_product', 'ts_filter_before_single_product');
function ts_filter_before_single_product() {
    global $product;

    if (ts_is_monday() && $product->get_id() !== ts_get_free_product_id()) {
        wc_print_notice(__('Get a free product with your purchase on Mondays!', 'woocommerce'), 'notice');
    }
}

// Cart and checkout validation + error message
add_action('woocommerce_check_cart_items', 'ts_conditionally_allowing_checkout');
add_action('woocommerce_checkout_process', 'ts_conditionally_allowing_checkout');
function ts_conditionally_allowing_checkout() {
    if (ts_is_monday()) {
        // Loop through cart items
        foreach (WC()->cart->get_cart() as $cart_item) {
            // Check cart items
            if ($cart_item['data']->get_id() === ts_get_free_product_id()) {
                // Set the quantity of the free product to one
                WC()->cart->set_quantity($cart_item['key'], 1);
                wc_add_notice(sprintf(__("You are eligible for a free product on Mondays."), "woocommerce"), 'notice');
                break;
            }
        }
    }
}
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 a customer visits the shop on ‘Monday’ and clicks on any product, notices indicating that the free product is exclusively available on Mondays are displayed on the product page of all products.

How to Add BOGO (Buy One, Get One) Offer for a Specific Day of the Week in WooCommerce? - Tyche Softwares

Subsequently, when the product is added to the cart, the free product gets added only on the specific day of the week i.e on Monday. To modify the day of the week on which free product should be offered, you should adjust the value of (date('w') == 1).

How to Add BOGO (Buy One, Get One) Offer for a Specific Day of the Week in WooCommerce? - Tyche Softwares

Similar to the free gifts offered on specific days of the week, you can also add a free gift based on time and date range in WooCommerce. By introducing time-based promotions aligned with special events or holidays, you can encourage customers to shop during these targeted periods and boost engagement with your store.

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