Posted on Leave a comment

How To Setup Buy 3 Get 1 Free In WooCommerce

discount rules woocommerce

You are a store owner and you want to run a promotional campaign that gives your customer one product for free for every 3 (or any other number) items they buy in a single order. Obviously, WooCommerce doesn’t support this kind of setup by default. Luckily for us, there is a plugin that does this job really well. That’s a plugin called Woo Discount Rules Pro.

Obviously, there are more discount rules you can setup using this plugin but we only focus on the buy x get y items for free in this post.

How to setup buy 3 get 1 for free using Woo Discount Rules Pro

Now, I suppose that you have the plugin installed and activated. Let’s go to WooCommerce->Woo Discount Rules:

accessing woo discount rules

You will see an interface like this:

woo discount rules pro interface

Our next step is to create a rule since we don’t have any rule here.

How To Setup Buy 3 Get 1 Free In WooCommerce 1

Let’s enter the details as above. Since we don’t have any rules yet, the priority box can be set to any valid number (positive). The validity field is where you can set at which period that this rule is effective. It’s all up to you to set this period. Now, let’s click next to the next screen.

create rules second screen

All fields in this screen are quite explanatory. It allows you to further customize the rule. For example, you can set this rule to be applied to customers who previously purchased from you (subtotal or number of items). You can also set the minimal subtotal of the current order to active the rule…

For now, we are going to apply the rule to all products (though you can add some products to the exception list if you want to).

Let’s click next to get to the last screen:

add the discount range

Let’s click on Add new range:

setup buy 3 get 1 free rule

Now, you can see that I’ve setup the rule to buy 3 (min quantity) so the customer can get one item of the same product for free. You are not limit to the item of the same product, in fact, you can have a bunch of options as demonstrated below:

How To Setup Buy 3 Get 1 Free In WooCommerce 2

You can see that, there are many options that you can customize to match your exact needs.

Now, I click on Save rule (located at the top).

See the buy 3 get 1 for free rule in action

Now, I’m going to buy 3 item of a single product. Let’s see the rule in action:

buy 3 get 1 free coupon woocommerce

As you can see, the rule displayed on the product page and when you view the cart, the subtotal is counted for only two products.

Conclusion

Woo Discount Rules Pro is not a free plugin but it add much more flexibility to your shop. It can also help you create loyal customer program (that rewards customers who previously bought products on the shop). If you are running a store, this is one discount rule plugin that you should have.

Thanks for reading the post. Make sure you check other WooCommerce Tips to help you build better eCommerce sites.

Posted on 1 Comment

How To Hide “Have a coupon? Click here to enter your code” On WooCommerce Checkout page

Coupon is a great way to make your customers happy. It is recommended that you use coupons when applicable. From my experience, having a coupon, even with a small discount can make the buying experience more pleasant. However, there are some stores, websites don’t use coupon. Take a consultant for example, she provides service at fix price per hour and normally, don’t offer discount. If she uses WooCommerce, on her checkout page, her customers see the message: “Have a coupon? Click here to enter your code” anyway. So, how can she remove that message?

have-coupon-message-on-checkout-page

How To Hide “Have a coupon? Click here to enter your code” on your checkout page

Some people may suggest you use CSS to hide the div that contains the message. While this method does the job, I would not recommend it. The reason is using CSS only hides the message, not remove it completely. In addition, WooCommerce has an option to disable that message, why don’t we use that?

So, to disable the message, you can go to WooCommerce->General and scroll down to the Enable Coupon section. You’ll see there is a checkbox there to let you enable and disable the use of coupons:

disable the use of coupons

As you can guess now, if you want to hide the message “Have a coupon? Click here to enter your code”, you should uncheck the checkbox “Enable the use of coupon codes”.

Next, scroll to the bottom and click on Save changes and you are done.

Conclusion

So, using coupons can be very effective for stores. However, you may not find it is applicable for your product. If you want to disable the use coupon on the checkout page, WooCommerce supports that by default and you can enable and disable it in WooCommerce settings.

Posted on 3 Comments

How To Get Product Type In WooCommerce

When developing plugins for WooCommerce, sometimes, knowing the product’s type is very important. The funny thing about WooCommerce is if you create a product from the class “WC_Product” and run:

$product->get_type();

The result is always simple.

This sounds confusing, doesn’t it? I feel the same way.

Get WooCommerce Product Type Using WC_Product_Factory

Since version 3.0, there is a convenient static method in WC_Product_Factory class that helps you get the type of product quickly:

WC_Product_Factory::get_product_type($product_id);

If the product is valid, you will get the product type as string (simple, variable…)

If the above method doesn’t work, let’s continue.

Getting product type using taxonomy

If you want the get_type method to return the correct type of the product, you need to create the product with the appropriate class. For example, for the get_type function to return ‘variable’, you need to create the product with the following syntax:

$product = new WC_Product_Variable($product_id);

However, how do you know what class to use when first creating the product?

The answer lies in the following code:

$terms = get_the_terms($this->product->get_id(), 'product_type');
$product_type = (!empty($terms)) ? sanitize_title(current($terms)->name) : 'simple';

As you can see from the code, it gets the taxonomy ‘product_type’ of the product and return the taxonomy name if exist, otherwise, it returns ‘simple’.

So, if you have the same problem, this is the code to use.

Posted on 1 Comment

How To Set Woocommerce Custom Shipping Cost Per Product

How To Set Woocommerce Custom Shipping Cost Per Product 3

The goal

Learn how to set custom shipping cost per product in WooCommerce.

The method

We are going to use WooCommerce shipping class to set different shipping cost per product.

What is a WooCommerce shipping class

This is the definition of shipping class on WooCommerce documentation. I think it’s clear enough:

Shipping classes can be used to group products of similar type and used by some shipping methods, such as Flat Rate Shipping, to provide different rates to different classes of product.

For example, for a specific shipping zone, when you select a shipping method, inside the shipping method, you can set many shipping classes. Each class can have different cost. This makes it very easy for us to set different shipping cost for each product.

How to set custom shipping cost per product using shipping classes

This is our setup: We have two products, a hat and a vase. A vase requires a more careful shipping method because it’s fragile while a hat can use less secure shipping method. Now, we are going to create two shipping classes:

  1. Fragile product shipping
  2. Normal product shipping

As you can guess, the vase will use the first class, the hat will use the second.

Add shipping classes

Let’s go to WooCommerce->Settings->Shipping class and add these two classes:

add new shipping class

Let click on the “Add shipping class” at the bottom right. You will see there are input boxes appear for you to enter the details. Don’t worry if you don’t see the place to enter shipping cost. We’ll do it later in shipping zones.

How To Set Woocommerce Custom Shipping Cost Per Product 4

Now click on Save Shipping classes and you are done.

Our next step is to create a zone and add shipping methods (if you haven’t got any).

Add shipping zone and shipping method

Let’s click on Shipping zones and click on Add shipping zone. You’ll see an interface appears to enter the zone details. In my example, I use Asia as my zone but you can use any other zones if you like.

add shipping zone

Now click on Add shipping method.

We are going to use the flat rate method.

Now, click on the edit link under the flat rate method:

How To Set Woocommerce Custom Shipping Cost Per Product 5

setting cost for shipping class

Here you can see that there are settings to enter Shipping class costs. In this example, I set 20 for the Fragile product shipping class and 5 for Normal product shipping.

Now, click on Save changes, click Save changes again on the add shipping zone screen and you are done with setting up shipping classes.

Set shipping class per product

Finally, we are going to set the shipping class for our products.

setting shipping class

Let’s go to the product data area (right under the product description area) and click on shipping. When you click on the “Shipping class” drop down, you’ll see the two options we’ve just created. Select Fragile product shipping for the vase and Normal product shipping for the hat.

Now, let’s add vase and hat to cart and go to the cart page. You’ll see the shipping cost is added accordingly:

shipping cost for vase
Shipping cost for vase

shipping cost for hat
Shipping cost for hat

shipping cost for both
shipping cost for both

Conclusion

As you can see, using shipping class can let us setup some flexible shipping for our product. There is no limit of number of shipping classes you can create so you can easily have many shipping options.

Posted on Leave a comment

How To Limit Max Order Quantity In WooCommerce

How To Limit Max Order Quantity In WooCommerce 6

As a shop owner, you may want to sell as many items as possible. However, there are cases you want to limit the number of items a single customer can purchase. The reasons can vary: maybe you have limited stock, maybe you don’t want a single customer stocks many items and reseller it later with much higher price… Whatever the reason, you will feel the need for a function to set the maximum number of item per product that a single customer can purchase. The good news is, there is a solution for that and it’s totally free.

Meet the plugin that enable max quantity of items that a single customer can purchase PER PRODUCT

Remember, the limit is PER PRODUCT (I’m sorry for the uppercase but this is important). For example, you have leather bag and plastic bag. You can set the quantity limit for leather bag is 2 and plastic bag is 3. So, your customer can order up to 5 items total but she cannot buy more than 2 leather bags or 3 plastic bags.

Now, let’s install this plugin called Woocommerce Max Quantity

Installing the plugin is very straightforward. You can search the plugin by entering its name in Plugins->Add new. You may need to scroll down a bit to see the plugin since at the time of this writing, it stays at the bottom of the first page.

After activation, go to the product you want to set the limit. Click on Inventory tab. You will see there is a new box appears to enable the max quantity. In the example below, a single customer can only purchase 4 fake lamborghini cars from my store:

Set max quantity for single customer on a product

Now, update the product and let’s go to the product page and try to order more than 4 items:

Max Quantity order per item Woocommerce

As you can see, the store sends a notice to customer when she tried to order more than the limit.

Conclusion

The plugin does a great job setting the limit for the order per single product. If any improvement needed, I think that’s a function to display the limit right below the order button so the customer can see the limit right before she enters the order quantity.