How to offer cheapest item in the cart as free gift in WooCommerce? (2 method)

Offer cheapest product in the cart as gift in WooCommerce
Table of Contents

WooCommerce cheapest cart item in the cart as free gift is one of the most popular marketing strategies online stores offer to boost their sales.

The customers adore the offer as they can receive a product for free when purchasing from your shop. The store owners can also benefit from it to attract more customers to the store.

In this post, we will explain how to set up a WooCommerce cheapest product as gift offer which means the cheapest item in the customer cart is added for free if the conditions are met. 

Method #1: Get the cheapest product in the cart for free gift in WooCommerce by coding

One of the quickest methods for offering WooCommerce cheapest cart item as a free gift is adding a code snippet to the functions.php file of the WordPress theme. Although this method is simple to use, we recommend you consider below notices before going through it:

  • Back up your WordPress data to restore the site in case of any problems after running the code.
  • Create a child theme to insert the code in the functions.php file.
  • Don’t use this method if you have no experience in coding, you can ask an expert to do this task.
  • Try a site-specific plugin like Code Snippets to add this code to WordPress.

Here, you can find the code snippet for giving WooCommerce cheapest item in the cart as gift:

add_action( 'woocommerce_before_calculate_totals', 'it_cheapest_cart_item_half_off', 9999 );
function it_cheapest_cart_item_half_off( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;
    if ( count( $cart->get_cart() ) < 2 ) return; // AT LEAST 2 PRODUCTS IN THE CART
    $min = PHP_FLOAT_MAX;
    // LOOP THROUGH THE CART TO FIND THE CHEAPEST ITEM
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
      if ( $cart_item['data']->get_price() <= $min ) {
        $min = $cart_item['data']->get_price();
        $cheapest = $cart_item_key;
      }
    }
     // LOOP THROUGH CART TO REDUCE CHEAPEST ITEM PRICE BY 50%
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
      if ( $cheapest == $cart_item_key ) {
        $price = $cart_item['data']->get_price() / 2;
        $cart_item['data']->set_price( $price );
        $cart_item['data']->set_sale_price( $price );
      }
    }
}

As illustrated in the below screenshot, after running the code, if customers buy some products from your store, the cheapest item in their cart will be offered to them for free. 

Cheapest item in WooCommerce cart for free by coding result

Method #2: Offer the cheapest item in the cart as gift with the free gift for WooCommerce plugin

The free gifts for WooCommerce plugin is a gamification plugin for creating meaningful promotional plans and marketing campaigns that are beneficial for both the store and the customers. You can use this plugin to offer several types of free gifts such as BOGO, buy x get y, subtotal amount, etc.

In this guide, you can learn how to offer WooCommerce cheapest item in cart as gift with this plugin.

woocommerce gift plugin banner

Step 1: Install the free gifts for WooCommerce plugin

Like other WordPress plugins, to use free gifts for WooCommerce on your website you need to install the ZIP file through a FTP server or WordPress installer. The installation process is easy and straightforward. However, in case of any problem, you can read this step-by-step guide to install the WooCommerce free gifts plugin.

Once you install and activate the plugin, you can see the Woo Free Gift menu in the WordPress dashboard. Click on this menu then the Rules| settings option to see the Rules page.

Select rules and settings submenu in Woo Free Gift menu

Step 2: Add a new rule and set the WooCommerce cheapest cart as gift method

On the Rule page, you can find the Add Rule button with a list of all rules that you have created before. To create a new rule, you need to press Add Rule to open a Rule Form.

Select Add Rule button in WooCommerce free gifts plugin

The Rule Form of free gifts for WooCommerce plugin contains all the options required for applying different free gift strategies with a dynamic design. It means when you choose your preferred method such as WooCommerce cheapest cart item as gift, the items in the form will be updated accordingly which makes the process of setup rules more convenient.

Add new rule form in free gifts for WooCommerce plugin

The first item you can see in the Add Rule form is Method. To start creating your rule, you need to open its dropdown list and choose your preferred method. By default, the most useful free gift offering methods are listed in this field such as buy x get x, simple, bulk quantity, tiered quantity, etc.

Select Cheapest item in the cart as free gift method in WooCommerce free gifts plugin

So, when you choose the Cheapest item in cart from the list field, the following sections will be displayed:

  • Quantities & Settings 
  • Products- Buy
  • Conditions
Add rule form section in WooCommerce free gifts product plugin

In the next steps, we will show you how to set items in the form to create and apply the cheapest product in the cart as gift in WooCommerce.

Step 3:  Set Quantities & settings

In the Quantities & Settings section, you should set the number of products customers must order to receive the gift. You can insert the quantity in the Buy field manually.

Select Buy field in  quantities & settings section of free gifts for WooCommerce plugin

For example, if you insert 4 in the Buy field, customers must order 4 items from your store to receive the cheapest one as gift.

Step 4: Add buy product items to offer WooCommerce cheapest cart product as gift

The next section which is Product  Buy allows you to add as many products as you need to apply the rule to. The customers should buy the products you have added here, to receive the free gift.

Add buy product items to offer WooCommerce cheapest cart product as gift

By pressing the Add Product button, a new row will be added in this section. Then you can select one of the below items to add your preferred products:

  • Product: To apply the rule to one or more specific products.
  • Product Variation: To apply the rule to one or more variations of products.
  • Product Category: To apply the rule to the products in one specific category. 
  • Product Attributes: To apply the rule to one or more attributes of products. 
  • Product Tags: To apply the rule on the products with the selected tags
Add desired products to offer WooCommerce cheapest cart product as gift

You can add unlimited rows to set different products in this section and encourage customers to buy the items you want to boost their sales.  

Step 6: Add conditions to offer WooCommerce cheapest item in cart as gift

In the last section, you can set various conditions to let the customers receive the gifts in specific situations. The conditions you can apply to the rule are divided into some categories helping you to easily find the terms to set up rules.

Add conditions to offer WooCommerce cheapest product in the cart as gift method

Let’s review the most useful condition terms:

  • Date: The terms in this category let you offer the free gift on a specific date or a date range. This is useful when you want to run marketing campaigns on popular occasions like Christmas, Black Friday, etc.
  • Cart: These terms allow you to offer the free gift when specific conditions related to the customer cart are met like cart subtotal price, cart total weight, cart item count, etc,
  • Cart items: If you want to limit your free gift offer based on cart items like products, variations, attributes, etc. use the terms in this category.
  • Checkout: This category allows you to set conditions for customer payment methods.
  • Checkout address: This term is useful when you want to limit the offer to customers from a specific country.
  • Customer: The terms in this category let you limit the free gifts offered to specific customers like the registered users.
  • Purchase history: You can use these terms to offer free gifts to customers who purchased specific products or amounts from your store in their past orders.

You can set as many conditions as you need to in this section to create complicated rules.

Conditions fields in the WooCommerce free gifts plugin rule form

When you fill all fields in the form, click on Save Changes to apply the rule to the specified products.

So, when customers order the selected products and their orders meet all specified conditions, they can receive WooCommerce cheapest item in cart as gift.

Example: Buy 3 products from blue or red products in the clothing category to get the cheapest product for free

In this scenario, we want to offer the cheapest item for free to the customers who order 4 items with blue or red variations from the Clothing category.

To apply this rule, try to:

  • Choose the Cheapest item in the cart from the list of Methods field.
  • Set 4 in the Buy field.
  • Add product row in the Product Buy section, and choose Product Attributes. Select At least one of the selected option from the second field, and select Red and Blue in the last field.
  • Add another product row, and select Product Category. Select In List option from the second field, and then Clothing from the last field.
  • Press the Save Changes button.
Set buy 3 products from blue or red products in the clothing category to get the cheapest product for free

As illustrated below, when a customer ordered 4 items from Red and Blue t-shirts, and add Cap to the cart. As you can see in the below, the Cap is the cheapest item in the cart. Based on cheapest item in the cart rule, a new Cap product is added to the cart automatically for free.

Buy 3 products from blue or red products result to get cheapest product for free in WooCommerce cart

Note: The gift is not always one of the products to which the rule applies. When customers order different products and their orders meet all of the conditions you have set in the rule form, automatically a new product with the cheapest price in the cart will be added to the cart for free.

Why do you need to use the plugin method?

Creating WooCommerce cheapest cart item as free gift offers with a plugin has many advantages over coding. Here, we review some of them:

  • User-friendly interface: Free gift for WooCommerce has an easy-to-use interface even for beginners. The hassle-free process of customizing the rule form makes it easy for all users to create several rules in a few seconds. 
  • Endless rules with easy management: You can create unlimited rules in this plugin and Enable/Disable them with one click.  
  • Safe: Free gift for WooCommerce plugin is compatible with all WordPress themes and third-party plugins. So, applying the rules has no harmful effect on your website.
  • Support all gift methods:  All free gift methods like buy x get x, buy x get y, subtotal, WooCommerce cheapest cart item as gift, and more are available in the plugin to help you run your campaigns with a few clicks.
  • No coding skill: There is no need to have coding knowledge to work with this plugin. Users have access to a dynamic form for setup conditions or creating rules. So, there is no need to insert several codes into the function.php file, every time you want to run a free gift campaign.
  • Flexible: All methods and conditions you may need to run your free gift campaigns have been designed in this plugin. Users can enjoy creating rules with high flexibility and no limitations.
  • Unlimited conditions: The plugin allows you to apply powerful rules on your site by adding various conditions. The conditional logic feature comes with so many options you can use to customize the rules.
woocommerce gift plugin banner

Conclusion

WooCommerce cheapest product in the cart as a gift offer has many advantages for eCommerce websites. Using this method encourages customers to buy more products to receive the gift. Although WooCommerce has no built-in option for offering free gifts in online stores, managers can use coding methods or plugins to apply flexible rules to their shop.

In this post, we provided a step-by-step guide about both methods. We also mentioned the most advantages of creating gift offers with the free gifts for WooCommerce plugin.

Leave a Reply

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

Captcha loading...