Patrick's Programming Blog

Disable Free Shipping on a per Product Basis in WooCommerce

Lego Fork Lift

Shipping is one of the most complex aspects of e-commerce. You have to worry about shipping provider regulations, large products that have awkward dimensions & box sizes, small products that the shipping calculators incorrectly estimate and you over charge, or you could have a mix match of product sizes and it's hard to come up with a fair flat rate shipping fee.

One of the approaches many store owners take is to mark up their products a little more and then offer free shipping. I think this is brilliant idea, but what happens if you have many small items and one large item that throws off the flat rate fee? If you're using WooCommerce there's a filter you can use to disable free shipping when a specific product is in the cart.

You simply have to get some information about your products, add that information to a little code snippet, and then put it in your functions.php file in your theme.

Getting the Product ID

WooCommerce product ID in address bar.

The only information you need about the product(s) is the product id. This can be done easily by going to the Product page and then editing any existing product. You'll see the ID in the address bar.

Add Product IDs to Snippet

Now that you have any IDs that you need you just need to add them to the $ineligible array in the following snippet. Then add this snippet to your functions.php file in your theme and upload it to your website.

Disabling Other Shipping Methods

If you offer free shipping why would also offer paid shipping? Especially if it's the same shipping provider. The snippet I provided works even better once you hide the other available shipping options when free shipping is available.

I hope this article makes your store a little more shipping friendly. 🙂

Photo Credit: Ricecracker. via Compfight cc

Exit mobile version