Code for developers who customize WooCommerce stores: cart and checkout changes, custom checkout fields with validation, order statuses and lifecycle hooks, custom emails, HPOS migration and the REST and Store APIs.
A custom WooCommerce order status: “Ready for pickup” WooCommerce’s order statuses (pending, processing, on hold, completed, cancelled, refunded, failed) do not fit every shop. A store with local pickup needs a step between “processing” and “completed”: the order is packed and waiting at the counter. A custom status shows that in the order list, can…
wc_get_product(): read and change WooCommerce product data A WooCommerce product is a post, but its data (prices, stock, SKU, dimensions, gallery) is managed by WooCommerce’s product classes. Since WooCommerce 3.0 the right way to read and change it is the product object returned by wc_get_product(), with getters like get_price() and setters plus save(). Reading post…
Add a custom field to the WooCommerce checkout page The WooCommerce checkout collects the usual data: billing and shipping address, contact details, payment method. Real shops often need more at the moment of purchase: a gift message, a preferred delivery time, artwork instructions, a company VAT number. The checkout is the right place for it,…