building a plugin to create inventory dependencies in WooCommerce

the problem.

There are many options for configuring your products when using WooCommerce for an online store. Within WooCommerce there are options for creating simple products, product variations, and grouped products. There are also many plugins available that allow you to group products together in different ways including chained products, product bundles, force sells, composite products, and mix and match products. Each of these plugins allows you to create product groupings in various ways, but none of them allow you to have a product in your store that is dependent on the inventory of a different product.

For example, let’s say your store sells bottles of your microbrewery beer but you also want to sell cases of six and 12 bottles. Using built-in WooCommerce functionality, you can create three different simple products, but each product will have its own inventory so you will have to decide in advance how many bottles of beer you want to sell in singles, in 6-packs, or in cases of 12. A slightly better approach would be to create a single variable product with variations for one, six, and 12 bottles. But again, each product variation will have its own inventory.

Going the plugin route, the one that fits this problem the best is the product bundles plugin. With this plugin, you can create your simple product for a single bottle of beer, and then create products that are bundles of six and 12 bottles. The big benefit of this approach is that you maintain inventory for only one product – the single bottle of beer – and you can sell multiple quantities of this product. The drawback with this plugin is that your customers will see in their cart and in the checkout that they are buying multiple of the individual items, which could be confusing.

the solution.

With the Stock Dependencies for WooCommerce plugin, you can create simple or variable products in your store and make their inventory completely dependent on the inventory of one or more products in your store. WooCommerce treats this as a single product in the cart and through the checkout process.

the delivery.

The Goalie Training Institute sells training sessions for goalies. Their training program is built around four key parts of the hockey year: in-season training that runs from September through March, a Christmas break camp, a spring tune-up program in April and May, and their very popular summer development program that runs June through August. Each part of their program is sold in packages of multiple sessions.

For the Spring 2020 sessions, GTI wanted to sell groups of training sessions in three configurations: 5 sessions on consecutive Sundays, 6 sessions on consecutive Tuesdays, or all 11 sessions. Also important, on each day in the program, GTI runs several sessions for different groups of goalies based on age and skill level.