This is a take home project so we can get an idea of your code skills and style.
This project should take between 2-3 hours and should be completed within a week.
By default, WooCommerce uses the WordPress post ID as the order number. We run several eCommerce websites for separate business units e.g. Custom Cages and Custom Aquariums. We need each order number to be unique.
We also need the order number to provide some contextual information about the order. This is helpful for reporting in our sales and accounting software.
The following constraints are documented here for reference latter, so we can look back on the reasons we made the decisions we did.
- QuickBooks will only accept order numbers that are 11 characters or less.
- Order numbers must indicate the business unit.
- Order numbers must indicate if the customer is a reseller.
- Order numbers must show the year and month the order was created.
- Order numbers must be unique. They cannot overlap with existing order numbers.
To satisfy all of these requirements the following format will be used for orders created by WooCommerce.
BYYMM-T0000
B
is a single character that represents the business unit.C
= Custom Cages,A
= Custom Aquariums,V
= Vision Products,S
= Serenity. ExampleC
for Custom Cages.YY
is the two-digit representation of the year the order is placed. Example20
for the year 2020.MM
is the two-digit, zero padded representation of the month the order is placed. Example07
for July.T
is the single character representation of the customer type.C
for a standard customer, andR
for a reseller.0000
is the zero padded, single incremented, sequential order number. This number resets to 0 each month. This number does not need to be unique across business units, since the business unit is indicated by the first character of the order number. Example0093
would be the 93rd order created that month.
The first order of July 2020 on Custom aquariums for a reseller, would be A2007-R0001
.
The twentieth order of November 2021 on Vision Products for a standard customer would be V2111-C0020
.
To make this work across all our WooCommerce stores we want to create a plugin that replaces the default WooCommerce order number with our custom order number.
Your job is to write the core of that plugin. You have the liberty to create it as you wish. However, the following requirements must be met for the plugin to be considered operable.
- The
WC_Order->get_order_number()
method must return the custom order number. - Order numbers must adhere to the above format.
- Each order number must be unique.
- There are no existing orders that need to be updated.
- A new user role
reseller
. - The website uses the latest version of WordPress and WooCommerce.
- Create your own repo public or private and build your plugin in that repository.
- Notify us in some manner (GitHub invite / email / phone / carrier pigeon) of your repository.