How to Offer WooCommerce Free Gift

How to Offer WooCommerce Free Gift (Easy Setup)

Study says the word “FREE” motivates people to buy differently. You know yourself, it’s true, right?

Who doesn’t love free stuff? How about offering free products as gifts in your WooCommerce stores?

It might sound like a money drain, but in reality, it can supercharge your sales and boost your revenue. 90% of customers who receive free gifts with purchases become loyal to a brand and return for more purchases, and 65% of them recommend the brand to others.

Our article will guide you in creating a WooCommerce free gift using different methods.

Let’s get started.

What is a WooCommerce Free Gift?

Offering a free gift in your WooCommerce store means you are offering a free product with a specific product or any purchases. You can create a WooCommerce free gift in multiple ways and combine it with multiple conditions.

The most common and popular WooCommerce free gift with purchase is called BOGO (Buy One Get One).

Here are some other common WooCommerce free gift conditions you can implement:

Cart Value:

  • Minimum Order Total: The customer must reach a specific minimum amount in their cart (e.g., $50 or more) to qualify for WooCommerce add free gift to cart.
  • Spend and Save: Offer a free gift at checkout WooCommerce when the customer spends a certain amount and another free gift for an even higher purchase amount (e.g., free tote bag for $25+ orders, free water bottle for $50+ orders).

Product Purchase:

  • Buy X Get Y (BOGO): A classic free gift strategy where a customer receives a free product (Y) upon purchasing another specific product (X) or a certain quantity of that product (e.g., buy one t-shirt, get a free pair of socks).
  • Category-Specific: Offer a free gift when a customer purchases a product from a particular category (e.g., free travel pouch with any travel accessory purchase).

Customer Behavior:

  • First Purchase: Incentivize new customers with a free gift on their first order.
  • Loyalty Program: Reward loyal customers with exclusive free gift offers.

Other Conditions:

  • Free Shipping Threshold: Combine free shipping with a free gift when the customer reaches a specific cart total.
  • Specific Products: Offer a free gift when customers purchase a particular product you want to promote.
  • Limited Time Promotions: Create a sense of urgency by offering a free gift for a limited time only.

Creating Free Gifts for WooCommerce

Despite being the champion amongst the eCommerce platforms, WooCommerce doesn’t have built-in tools to offer free product gifts to your customers.

However, you can create a WooCommerce free gift in multiple ways.

  1. Using Custom Codes
  2. Using Coupons using a Coupon plugin
  3. Using a Free Gifts for WooCommerce Plugin

Let’s start with the custom codes.

Creating WooCommerce Free Gift using Custom Codes

WooCommerce allows you to add custom codes to the theme files to add more functionalities to the core features. Similarly, you can add free gift with purchase WooCommerce using custom codes.

We have previously covered different BOGO deals using custom codes in detail. Let’s create a WooCommerce free gift for some different conditions or situations.

  • Get A Specific Product For Free On Buying X Products
  • Buy X Amount of Products from a Specific Category And Get Y For Free

Get a Specific Product for Free on Buying X Products

Let’s say, you want to offer a cap as a free gift when the customers adds 2 items to the cart. Here’s a step by step guide to add free gift WooCommerce on cart items added using codes.

Backup Your Site:
  • Always back up your site before making any changes to the code.
Access the Theme’s Functions.php File:
  • You can edit this file via FTP, cPanel, or directly through the WordPress Admin Dashboard by navigating to Appearance >> Theme Editor >> functions.php.
theme file editor
  • Scroll down to the bottom and paste your code in the free space.
edit fucntions to add WooCommerce free gift
Add Custom Code:
  • Insert the following custom code into your functions.php file.
function add_free_product_with_two_items() {

  // Define the targeted product ID for free offer

  $free_product_id = 123; // Replace with your actual product ID

  // Define the minimum required product count (excluding free product)

  $minimum_product_count = 2;

  // Get the cart items

  $cart = WC()->cart->get_cart();

  // Initialize variables

  $non_free_product_count = 0;

  $free_product_exists = false;

  // Loop through cart items

  foreach ($cart as $cart_item) {

// Check if it's not the free product (based on custom price)

if (!isset($cart_item['custom_price'])) {

   // Increase non-free product count

   $non_free_product_count++;

} else {

   // Check if free product is already added

   $free_product_exists = true;

}

  }

  // Add the free product if conditions are met

  if ($non_free_product_count >= $minimum_product_count && !$free_product_exists) {

WC()->cart->add_to_cart($free_product_id, 1, 0, array(), array('custom_price' => 0));

  }

}

// Hook the function to 'woocommerce_before_calculate_totals'

add_action('woocommerce_before_calculate_totals', 'add_free_product_with_two_items');
Code Explanation
  • This code defines a $minimum_product_count variable to specify how many non-free products are required to trigger the free offer.
  • The loop checks for cart items that don’t have a custom_price set (indicating non-free products).
  • It then verifies if the free product (identified by custom_price set to 0) is already in the cart.
  • If the non-free product count meets the minimum requirement and the free product isn’t present, it adds the free product with a quantity of 1 and a custom price of 0 to the cart.
How to Get the Free Product ID and Place it in the Code

Noticed this line –   $free_product_id = 123; // Replace with your actual product ID

You need to replace 123 with your cap product ID. To collect the ID, navigate to Products >> All Products. Hover over the product, and the ID will appear in the edit panel.

product id

Copy and replace it in the code.

Function to Apply Custom Price

Add these codes below the previous codes.

function apply_custom_price($cart_object) {

  foreach ($cart_object->get_cart() as $cart_item) {

if (isset($cart_item['custom_price'])) {

   $cart_item['data']->set_price($cart_item['custom_price']);

}

  }

}

add_action('woocommerce_before_calculate_totals', 'apply_custom_price');
Test the Functionality

Add any 2 products in the cart. How do you show free gift item in cart woo commerce?

You don’t; the system will do it automatically, per our code. Jump to the cart page.

WooCommerce free gift

As you can see, WooCommerce added the cap as a WooCommerce free gift.

Buy X Amount of Products from a Specific Category And Get Y For Free

Let’s say you want WooCommerce add free gift to products from a specific category. For example, when customers add 2 hoodies, they will get a cap for free.

Here are the steps –

Code Implementation
  1. Add a Function to Add Free Cap with Hoodies:
// Function to add free cap when buying 2 hoodies

function add_free_cap_for_hoodies_offer() {

// Define the hoodie product category slug

$hoodie_category_slug = 'hoodies';

// Define the free cap product ID

$free_cap_product_id = 164; // Replace with your free cap product ID

// Get the cart items

$cart = WC()->cart->get_cart();

// Initialize counters and flags

$hoodie_count = 0;

$cap_in_cart = false;

// Count the number of hoodies in the cart and check if the free cap is already added

foreach ($cart as $cart_item) {

     $product_id = $cart_item['product_id'];

     if (has_term($hoodie_category_slug, 'product_cat', $product_id)) {

         $hoodie_count += $cart_item['quantity'];

     }

     if ($product_id == $free_cap_product_id) {

         $cap_in_cart = true;

     }

}

// Add the free cap if there are at least 2 hoodies and the free cap is not already in the cart

if ($hoodie_count >= 2 && !$cap_in_cart) {

     WC()->cart->add_to_cart($free_cap_product_id, 1, 0, array(), array('free_cap_offer' => true));

}

}

add_action('woocommerce_before_calculate_totals', 'add_free_cap_for_hoodies_offer');
Explanation:
  • Function Purpose: This function checks the cart before WooCommerce calculates totals (woocommerce_before_calculate_totals hook).
  • Variables:
    • $hoodie_category_slug: Replace with the slug of your “Hoodies” category.
    • $free_cap_product_id: Replace with the ID of your free cap product.
  • Cart Loop:
    • It loops through each item in the cart.
    • Counts the quantity of items categorized under “Hoodies”.
    • Checks if the free cap is already in the cart ($cap_in_cart flag).
  • Adding the Free Cap:
    • If there are at least 2 hoodies ($hoodie_count >= 2) and the free cap is not already in the cart, it adds the free cap to the cart with a price of 0 (WC()->cart->add_to_cart()).
Apply Custom Price
// Function to apply custom price (if required)

function apply_custom_price($cart_object) {

foreach ($cart_object->get_cart() as $cart_item) {

     if (isset($cart_item['free_cap_offer'])) {

         $cart_item['data']->set_price(0);

     }

}

}

add_action('woocommerce_before_calculate_totals', 'apply_custom_price');
Explanation:
  • Function Purpose: This function sets the price of any item marked as a free cap (‘free_cap_offer’ flag) to 0.
  • Cart Loop:
    • It loops through each item in the cart.
    • Checks if the item has ‘free_cap_offer’ set.
    • Sets the price of the item to 0 if it meets the condition ($cart_item[‘data’]->set_price(0)).
Implementation Steps:
  1. Replace Product IDs:
    • Replace $free_cap_product_id with the actual ID of your free cap product.
    • Adjust $hoodie_category_slug with the slug of your “Hoodies” category.

Add two hoodies to your cart.

WooCommerce free gift

As you can see, it’s working perfectly.

Using Coupons using a Coupon plugin to create a WooCommerce Free Gift

You can use the free plugin called Smart Coupons For WooCommerce to create a WooCommerce free gift coupon. It adds additional functionalities to your existing WooCommerce coupon tool.

WooCommerce free gift plugin

Most importantly, the free version of this plugin allows you to add BOGO deals and create automatic WooCommerce free gift vouchers.

Let’s start by adding a new coupon.

add coupon

Select BOGO from the discount type dropdown.

select BOGO

Select the expiry date and the number of times a customer can apply this coupon.

BOGO details

Let’s say you want to offer a free cap when customers buy one or more specific products. Jump to the Usage Restriction tab and scroll to the products section.

select products

This WooCommerce gift card plugin free tool adds multiple functions to this page. Search and add the products to which you want to apply the WooCommerce free gift offer.

The Giveaway Products tab is where you set the WooCommerce free gift. Search and select the cap product and set the discount to 100%.

select product for WooCommerce free gift

Add a coupon code and publish the coupon.

coupon URL

Applying the coupon

Now, there are multiple ways you can apply this coupon. You can promote free gift coupon WooCommerce vouchers in your marketing channels by backlinking the coupon link, and the system will automatically apply the coupon.

Customers can manually apply the WooCommerce free gift coupon using the coupon code.

Additionally, the plugin lets you apply the coupon automatically when the required terms are met. Let’s enable this option and jump to the shop page.

automatically apply WooCommerce free gift

Add the two products you selected to the Usage Restrictions page and go to the cart page.

WooCommerce free gift

The coupon is automatically applied. Let’s uncheck the automatic option and display a WooCommerce gift cards free banner on our cart page.

cart page

Go back to the cart page, and you will see a banner at the top.

coupon banner

Click on the banner and WooCommerce will apply the WooCommerce free gift for you.

Using a Premium WooCommerce Free Gift Plugin

Be it any sort of conditional discounts, BOGO deals, category-based discounts, or first-order discounts, you can create almost any type of discount in WooCommerce using the plugin called Discount Rules for WooCommerce.

We have shown detailed walkthrough of this plugin in our previous articles; today we will focus only on creating free gifts using this free gift WooCommerce plugin.

Let’s offer a free cap when customers add products worth $100 or more to the cart.

add WooCommerce free gift rule

Select Buy X and Get Y from the discount type dropdown.

select BOGO

Select all products for this WooCommerce free gift.

all products

From the Discount tab, search and select your products. In addition to that, make sure you select the following options.

discount conditions

Add a condition in the Rules tab.

add condition for WooCommerce free gift

Select Subtotal and input your value.

subtotal condition

Save your discount rule and check it from the front end. Here’s the cart page after adding $100 worth of products.

WooCommerce free gift

Let’s say you want to offer a free cap to your loyal customers who have spent a minimum $500 at your store. Here’s how to do it.

All other settings will be same. From the Condition Type dropdown in the Rules tab, select Total Spent.

total spent

Enter your minimum value and optionally select the customer’s order statuses.

WooCommerce free gift condition

You can create a wide range of discounts with this free gift WooCommerce plugin. You can check our previous articles to learn about them.

Wrap up

Offering free gifts in your WooCommerce store can significantly boost your sales and revenue. Most importantly, a WooCommerce free gift can turn visitors or first-time buyers into loyal customers.

However, you must be in the know to properly promote these free gifts to your customers. Let us know if you have any questions.

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

5,913,336+ Downloads. 610+ plus 5-star ratings. Promote products on any platform you want.