How to Create a BOGO (Buy One Get One) in WooCommerce

How to Create a Flexible BOGO (Buy One Get One) Offer in WooCommerce with Code

WooCommerce is powerful, but when it comes to running dynamic promotions like Buy One Get One Free (BOGO), it requires some custom code. In this blog post, you’ll learn how to implement a flexible BOGO deal that gives customers the option to receive a free product — either the same product or a different one — when they purchase a qualifying item.

What We’ll Build

A WooCommerce feature where:

  • When a customer adds a qualifying product to their cart,
  • They see a prompt to choose a free product (same or from alternatives),
  • Once selected, the free product is automatically added to the cart,
  • The free product is labeled and excluded from normal pricing logic.

Use Case Example

Buy 1 of Product A (ID: 123) and get one of the following free:

  • Product A (same)
  • Product B (ID: 456)
  • Product C (ID: 789)

Step 1: Show Free Product Options Notice

Add the following to your theme’s functions.php file or a custom plugin.

This snippet checks if the trigger product is in the cart and shows buttons to pick a free product.


Step 2: Add the Chosen Free Product to Cart

This code ensures that only one free product is added, and only if the trigger product is in the cart.


Step 3: Label the Free Product in Cart

This adds a label to the cart so the customer knows it’s a promotional free item.


Results

  • Works with simple products (can be extended to variations).
  • Customers can pick from same or alternative free products.
  • Easy to maintain and modify.

Bonus Ideas

  • Expand to Buy 2 Get 1 Free logic.
  • Add an admin interface to define BOGO rules.
  • Use a modal or dropdown for choosing free product instead of URL param.

Conclusion

With this custom code, you can run flexible BOGO promotions on your WooCommerce store without installing bloated plugins. It gives you full control over logic, styling, and scalability.

Let me know if you want this turned into a standalone plugin or extended to handle more complex conditions!

Crazy about CRO?

Dessert Calories Don’t Count

Our Sales Funnel Strategy does.

We don’t spam! Read more in our privacy policy

Leave a Reply

Your email address will not be published. Required fields are marked *