Add Free Product to Cart in WooCommerce

How to Add Free Product to Cart in WooCommerce – A Step-by-Step Guide

The biggest weapon and quickest technique to make a customer loyal to your brand is to offer a free product with their purchases. The word FREE has a significant psychological impact on buyers.

Don’t take our word for it; study says 90% of customers who receive free products with their purchases will become loyal to your brand. Moreover, 65% of them will recommend your online store to others.

By giving away something for free, you can incentivize purchases, encourage larger order values, and build customer loyalty.

And the best platform for offering free products with purchases is?

No surprise there, it’s WooCommerce. This monster of a powerful platform allows you to offer free product with purchases just the way you wish.

In this article, we will discuss WooCommerce add free product to cart. We will explore ways you can add free product to cart WooCommerce and provide real-life examples.

Let’s get started.

When to Apply WooCommerce Add Free Product to Cart

The timing of your free product offer can significantly impact its effectiveness. Here are various scenarios to consider:

Based on Order Value

  • Spend Threshold: Offer a free product when a customer’s order total is specific. For instance, “Spend $100, get a free .”
  • Tiered Rewards: Implement a tiered system where customers receive different free products based on spending levels.

Based on Product Purchase

  • Complementary Products: Offer a free item that complements a purchased product. For example, a free case with a phone purchase.
  • Product Bundling: Include a free product as part of a product bundle to encourage larger purchases.
  • Category-Based: Offer a free item when a customer purchases from a specific product category.

Customer-Centric Offers

  • Loyalty Rewards: Reward returning customers with a free product after a certain number of purchases or a specific spending amount.
  • New Customer Welcome: Offer a free product to welcome new customers to your store.
  • Referral Incentives: Provide a free product to customers who refer friends or family.

Seasonal and Promotional Offers

  • Limited-Time Offers: Create urgency by offering a free product for a limited time.
  • Holiday Promotions: Offer a free product during specific holidays or seasons.
  • Clearance Sales: Incentivize purchases of clearance items with a free product.

Strategic Considerations

  • Inventory Levels: Ensure you have sufficient stock of the free product to avoid stockouts.
  • Product Profitability: Consider the profitability of the free product and its impact on overall order value.
  • Customer Segmentation: Target specific customer segments with tailored free product offers.
  • Testing and Optimization: Experiment with different free product offers to determine the most effective strategies.

By carefully considering these factors, you can optimize the timing and nature of your free product offers to maximize their impact on sales and customer satisfaction.

Methods to Add Free Product to Cart WooCommerce

There can be multiple ways to offer WooCommerce add free product to cart, but there are two primary ways to set up these offers.

  1. Using Custom Codes
  2. Using a Dedicated Plugin

Let’s start with adding WooCommerce automatic free product to the cart using custom codes.

WooCommerce Automatically Add Free Product To Cart Using Custom Codes

In this example, we want to give away a cap as a free gift when a customer adds two items to their cart. Below is a step-by-step guide on WooCommerce add free product to cart programmatically using custom code.

1. Backup Your Website

Before making any changes to your website, always create a backup. This ensures you can restore your site if anything goes wrong.

2. Access Your Theme’s Functions.php File

You can edit the functions.php file through FTP, cPanel, or directly in your WordPress Admin Dashboard by navigating to Appearance >> Theme Editor >> functions.php.

funcitons - WooCommerce Add Free Product to Cart

Once inside the editor, scroll to the bottom of the file and find a space to paste your custom code.

3. Add the Custom Code

Now, insert the following code into the functions.php file:

function add_free_product_with_two_items() {

// Define the ID of the free product

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

// Set the minimum number of products required to trigger the free gift

$minimum_product_count = 2;

// Retrieve cart items

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

// Initialize variables

$non_free_product_count = 0;

$free_product_exists = false;

// Loop through each item in the cart

foreach ($cart as $cart_item) {

     // Check if the item is not the free product

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

        // Count non-free products

         $non_free_product_count++;

     } else {

         // Check if the free product is already in the cart

         $free_product_exists = true;

     }

}

// If the conditions are met, add the free product to the cart

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 the WooCommerce calculation

add_action('woocommerce_before_calculate_totals', 'add_free_product_with_two_items');

Code Breakdown:

  • The $minimum_product_count variable defines how many items must be in the cart (excluding the free product) to trigger the offer.
  • The loop checks for items in the cart that don’t have a custom_price set, meaning they aren’t free.
  • If the required number of products is met and the free product isn’t already in the cart, the code adds the free product to the cart with a custom price of 0.

4. Find the Free Product ID

Locate the product ID you want to offer as a gift.

To do this, go to Products >> All Products in your WordPress dashboard. Hover over the desired product, and you’ll see the ID in the edit options.

collect id

Replace the 123 in the code with this ID.

5. Apply the Custom Price

Add this additional code below the previous function to ensure the free product has the correct price:

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');

6. Test the Setup

Add any two products to your cart and visit the cart page. You should see the cap automatically added as a free gift.

WooCommerce Add Free Product to Cart

This setup helps WooCommerce add the cap to the cart without any extra steps for the customer, enhancing their shopping experience.

WooCommerce Free Product Based On Customer Using Custom Codes

Let’s say we want to offer WooCommerce add free product to cart for first-time customers. To add this first-order discount, add the following code to functions.php.

function add_free_gift_for_first_order() {

// Define the free product ID

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

// Get the current user ID

$current_user = wp_get_current_user();

$user_id = $current_user->ID;

// Check if the user has made previous orders

$customer_orders = wc_get_orders(array(

     'customer_id' => $user_id,

     'limit' => -1,

     'status' => array('completed', 'processing', 'on-hold')

));

// If no previous orders, and user is logged in, add the free product to the cart

if (empty($customer_orders) && is_user_logged_in()) {

     $cart = WC()->cart;

     $free_product_exists = false;

     // Check if the free product is already in the cart

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

         if ($cart_item['product_id'] == $free_product_id) {

             $free_product_exists = true;

             break;

         }

     }

     // Add the free product to the cart if it's not already added

     if (!$free_product_exists) {

         $cart->add_to_cart($free_product_id, 1);

     }

}

}

// Hook the function to WooCommerce before calculating totals

add_action('woocommerce_before_calculate_totals', 'add_free_gift_for_first_order');

Find and replace the product ID as you have seen before. If you want to set a custom price (e.g., $0) for the free product, you can add this additional code:

function apply_custom_price_for_free_gift($cart_object) {

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

     if ($cart_item['product_id'] == 123) { // Replace 123 with your free product ID

         $cart_item['data']->set_price(0); // Set price to $0

     }

}

}

add_action('woocommerce_before_calculate_totals', 'apply_custom_price_for_free_gift');

Log in as a new customer and place an order to ensure the free gift is added correctly. If all goes well, your store will now offer customers a WooCommerce conditional free product on their first order.

WooCommerce Add Free Product to Cart Using a Plugin

We will use a free WooCommerce plugin to add multiple products to cart. This plugin is called Discount Rules for WooCommerce.

Whether you want to create WooCommerce free product based on cart total or any other type of complex conditional discounts, you can create them with this plugin effortlessly.

We will create several examples of WooCommerce add free product to cart scenarios with this plugin in the following paras.

WooCommerce Free Product with Purchase Over a Certain Amount

Let’s say you have a clothing store and want to offer a free cap when a customer adds a minimum of $100 worth of products. Let’s create this WooCommerce add free product to cart discount using the plugin.

Go to WooCommerce >> Discount Rules and click the following button.

add WooCommerce Add Free Product to Cart rule

Input the discount rule name and select the Buy X and Get Y option from the discount type field.

buy x get y

Select all products for this WooCommerce add free product to cart.

select all products

The Discount tab is where you need to set up the discount rules. You can follow the below settings.

discount rules for WooCommerce Add Free Product to Cart

The Rules tab will allow you to set your subtotal condition. Hit the button.

add condition

From the Condition Type dropdown, select the Subtotal option. After that, input your value.

set subtotal rule

Let’s test our WooCommerce add free product to cart discount rule. Add $100 worth of products to the cart.

WooCommerce Add Free Product to Cart

It works like a charm, right?

WooCommerce Add Free Product to Cart Based on Customer Purchase History

Let’s say, you only want to offer the free cap to the customers who have spent a minimum total of $500 previously in your store. All settings will be same as before.

You just need to add a different condition. From the Condition Type in the Rules tab, select the condition Total Spent.

total spent condition

Insert your predetermined value. You can also select the order statuses that can avail of this discount.

condition for WooCommerce Add Free Product to Cart

Creating Standard Buy One Get One Free Product Deal

BOGO deals are by far the most popular deals for customers. Let’s create a BOGO WooCommerce add free product to cart deal.

Select Buy X, Get X from the discount type dropdown.

buy x get x

We want to offer a BOGO deal for a specific product. To do so, select Product from the Filters tab and select the targeted product.

specific product

From the Discount tab, set your minimum and maximum quantity required to avail of the discount. After that, select Free.

set rule

Add the product in the front end to test the rule.

WooCommerce Add Free Product to Cart

Best Practices for Offering Free Products

To ensure your WooCommerce add free product to cart offer is successful, consider these essential best practices. By following these guidelines, you can optimize your campaign and maximize its impact on sales and customer satisfaction.

Clearly Communicate the Free Product Offer and Its Conditions

  • Be explicit: Clearly state what the free product is and the conditions required to receive it.
  • Visibility: Ensure the offer is prominently displayed on product pages, cart, and checkout pages.
  • Transparency: Clearly outline any limitations, such as minimum purchase amount or product exclusions.
  • Easy to understand: Avoid complex or confusing terms and conditions.

Ensure the Free Product Complements the Purchased Items

  • Relevance: The free product should be relevant to the customer’s purchase or align with their interests.
  • Value: The free item should provide perceived value to the customer and enhance their overall shopping experience.
  • Complementary nature: Consider how the free product can be used in conjunction with the purchased items.

Set Reasonable Limitations on Free Product Offers

  • Quantity limits: Restrict the number of free products per order to prevent abuse.
  • Cart total minimum: Establish a minimum order value to qualify for the free product.
  • Product exclusions: Specify which products are eligible or ineligible for the free offer.
  • Time limits: Implement a specific timeframe for the free product offer to create urgency.

Track the Success of Your Free Product Campaign and Adjust Accordingly

  • Key metrics: Monitor sales, average order value, conversion rates, and customer satisfaction.
  • Analytics: Use analytics tools to track the performance of the free product offer.
  • Customer feedback: Gather customer feedback to understand the offer’s impact.
  • A/B testing: Experiment with different free product offers to identify the most effective strategies.
  • Adjustments: Modify the offer based on performance data and customer feedback.

Wrap up

Offering a free product is great way to entice your visitors to turn into paying customers. Moreover, it can allure them to turn into loyal returning customers.

However, you must have an effective discount strategy in place to avoid losses in your WooCommerce business. We hope this WooCommerce add free product to cart will help you setup these discounts and grow your store business.

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.

6,157,246+ Downloads. 627+ plus 5-star ratings. Promote products on any platform you want.