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

How to Create BOGO (Buy One Get One) Offers for First Time Website Visitors in WooCommerce?

Every customer feels a bit unsure when shopping at a new store for the first time. However, offering a free gift through a BOGO (Buy One Get One) offer reduces the hesitation. It lowers the perceived risk of trying out something new and encourages them to make a purchase because of the added value they receive. When first-time visitors have a positive experience and get a free gift, they’re more likely to tell others about it. This word-of-mouth can boost your store’s visibility and bring in new customers.

Solution: Create BOGO (Buy One Get One) Offers for First Time Website Visitors

The below code snippet will add a a specific product (identified by ID 34) is automatically added to the user’s cart as free gift only for first time visitors.

add_action( 'template_redirect', 'ts_add_product_to_cart_on_first_visit' );

function ts_add_product_to_cart_on_first_visit() {
    if ( ! is_admin() ) {
        $product_id = 34;

        // Check if it's the user's first visit
        if ( ! isset( $_COOKIE['first_visit'] ) ) {
            // Set a cookie to track the user's visit
            setcookie( 'first_visit', '1', time() + ( 30 * 1 * 60 * 60 ), '/' );

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

            // If the product is not found, add it to the cart
            if ( ! $found ) {
                WC()->cart->add_to_cart( $product_id );
            }
        }
    }
}
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 the customer visits the website, then the free product i.e. ‘Hoodie with Logo” will get automatically added to the WooCommerce cart page.

BOGO (Buy One Get One) Offers for First Time Website Visitors

In another scenario, if the customer visits the website for the second time, then the free product (Tshirt with logo) will not be added to the cart.

How to Create BOGO Offers for First Time Website Visitors in WooCommerce

Just as you welcome first-time visitors with special offers, you can also reward your loyal customers or those who make frequent purchases. One way to do this is by offering BOGO (Buy One Get One) gifts to high-value customers through WooCommerce.

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