wc-order-status
Adding custom order statuses to the Woocommerce platform could be definitely easier - and I am not talking about installing yet another plugin for dealing with silly tasks. This helper aims to automate and incept some intelligence to the way developers and web designers add, manage, style and even link behaviours and reactions to the custom statuses created.
First and foremost, we established a class to make the painful routine of adding custom statuses a single line of code.
Installation
No additional plugins, please. This library can be installed using Composer or, if you prefer, just download the main class OrderStatus
and add to your project.
Usage
By definition, for adding a new status to WC orders we first need to register such status in Wordpress, and then include the newly added status to the pool where order statuses are saved within Woocommerce. So... why not doing that at once, instead of successive functions and hooks? So let's see how to simply add new statuses:
use WPH\WC\OrderStatus;
// Composer autoload
require __DIR__ . '/vendor/autoload.php';
/
* Follow the format:
new OrderStatus(STATUS_NAME, array(BACKGROUND_COLOR,FONT_COLOR*));
* And that's it.
*/
new OrderStatus('Custom Status', array('orange', '#ededed'));
Obs: any CSS predefined color name and HEX color will work, but also any other format accepted in CSS (rgb, rgba, hsl, hsla).
Todo
We are planning some new features shortly. With new statuses, sometimes we face the need of trigger or hook functions or actions to them. So it makes sense to generate a controller class where you can encapsulate any kind of desired behavior. Also, we expect to add:
-
An easy way of customizing table actions and icons for new statuses
-
Autogenerated email templates for them
- Support for Woocommerce Subscriptions