Book Image

WooCommerce Cookbook

By : Patrick Rauland
Book Image

WooCommerce Cookbook

By: Patrick Rauland

Overview of this book

Table of Contents (17 chapters)
WooCommerce Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Enabling free shipping on a per product basis


The Free Shipping method that comes with WooCommerce is pretty flexible. What it's not great at is allowing a store to mark one or two items to use free shipping for and leave the rest of the products to use your other shipping methods. We can use the shipping classes built into WooCommerce combined with a little bit of code to mark any number of products eligible for free shipping.

Getting ready

Make sure you have the free shipping method enabled on your site.

How to do it…

In order to enable free shipping on a per product basis, go through the following steps:

  1. The first step is to create the shipping class we're going to use to mark items eligible for free shipping. If you don't know how to create shipping classes, see the Creating shipping classes recipe in this chapter.

    Once you have a shipping class, you need to copy the shipping class Slug, which we can use to identify that shipping class in the code.

  2. On the right-hand side of the Shipping Classes...