At WisdmLabs, we are advocates of the WooCommerce plugin. We recommend WooCommerce to clients, build extensions for the plugin, discuss related developer tips and tricks in our blog; all of this, because we’ve worked a lot with it, and know its ins and outs. Hence we are aware that, WooCommerce has its limitations. When it comes to order management and shipping, the functionality offered is a bit lacking.
Last week, we had explained how to integrate WooCommerce with an external Order Management System. This is a good solution, if you want a standalone system to manage orders. But for those of you looking to incorporate minor changes, using an external system might be going overboard, with a solution. Instead, a simple customization could suffice.
For example, say a client asked you, to divide orders based on products, create invoices for each order, and a monthly order summary sheet, which as you know, are available in say XYZ Order Management system (warning: just a hypothesis, do not Google XYZ Order Management System). In this case, you could consider integrating an external order management system with WooCommerce, to provide a structured solution. But say, the requirement was to add an option to edit details in an order, you could create a simple add-on to extend the basic WooCommerce functionality.
The question of course, is how does one go about customizing the WooCommerce plugin (or creating an extension plugin), to modify the WooCommerce Order module.
Before we delve into this, let’s take a look at some basics.
What is an Order in WooCommerce?
In WooCommerce, an order is a custom post type. By default, you can change the details, add custom fields, or notes, and set the order status. Simple customization, like adding a new status to the order (Add a Shipped Order Status in WooCommerce), would involve adding a new term in the custom taxonomy.
But say the requirement, was a bit more involved. Like having to set a shipped status on a per product basis in an order, or to track the number of product units shipped in an order. For this, we would have to make product details part of each order, editable.
For today, let’s postulate how we can track the number of units which have been shipped in a WooCommerce Order, by allowing the store admin, to update order details, by adding additional fields to each product item.
How to Customize a WooCommerce Order to Track Products Shipped?
In an order, a customer might purchase several products at once. Additionally, he/she could purchase more than one unit, of a particular product. Let’s consider the below scenario. Say you have two products A and B. A customer purchases 5 items of product A and 3 items of product B. If you go to the placed order, in your site’s dashboard, you should be able to see the order details placed. By default, you can edit the total quantity of the items, or delete items, or add items to the order.
Now let’s say, that as a store owner, you can’t ship all the products at once. Instead, you can ship products in segments or in batches of 2. In this case, you would need to keep track the quantity of products which have been shipped, and quantity still pending in the shipping pipeline. Since shipment tracking is not part of WooCommerce, we will have to track the details manually. But as part of the order itself. We will have to allow the store admin, i.e. you, to update details about the products which have been shipped, by adding additional fields to each line item.
What we have to do here, is divide the quantity section into three. One which would contain the original quantity ordered, the other would contain items shipped, and the difference of the two. A ‘Dispatch Date’ column can also be added, to track the last shipment dispatched.
To add additional columns to the order details, you have to use the ‘woocommerce_admin_order_item_headers’ hook. This hook can be used to add details between the ‘Item’ and ‘Qty’ columns. To populate these fields with values, you will have to use the ‘woocommerce_admin_order_item_values’ and ‘woocommerce_save_order_items’ hooks.
Every column added, can be edited by the store admin, to update values as and when products are shipped. The ‘Qty Left’ column is not editable, but the value is calculated as the difference of ‘Original Qty’ and ‘Qty’ columns.
Are you thinking about adding such a functionality in your WooCommerce store? But do your requirements differ? I would like your views on this. This customization was provided for a client project, but your usecase might be different. It would help, if you could utilize the comment section below, and put forth your needs, so as to help me come up a comprehensive solution. 🙂