On my client’s site, the user fills out a relatively complex CF7 form for their school, on which the user makes class and payment schedule selections. The students, max 5 per parent/user, are then sorted according to class levels, and the associated product and price values are sent to WC, among other things.
With a single click of the Submit button, the following occurs:
1. new user WP account is created
2. account is populated (or updated) with WC user_meta
3. WC order is generated
4. various custom emails are sent to school personnel and the customer
5. several other operations happen behind the scenes
There’s a hold placed on each order and site access/login is blocked until the client approves the user’s application form. Once approved, the user is taken to a page upon login which explains how the user needs to pay (school has specific payment processes). There’s a button on that page, which takes the user directly to checkout when they’re ready to proceed, and in checkout they’re presented with payment options for completion of the order.
Once that initial order goes thru, the user can’t check out again with the same order without the admin soft-cancelling the order via aforementioned status change. Without the admin changing status, the user would have to fill out the complex form again so the order could get compiled and go thru the whole process all over again. With the order status change, the user can just login again and be taken to checkout and done.
The need for quick and easy repeating of the same order is in cases where a user’s role needs to be changed, based on other various things that occur on the site (I’ve set up many different roles/levels for users and school staff), or if a simple order edit is needed. The order number needs to be retained as well, for site operations and bookkeeping purposes.
Basically, instead of the CF7 form submission firing events/functions to make WC (and UM) do things, I want the order status change in WC’s admin UI to fire functions that make UM and WP account handler do things.
A major reason I want to do all of this by just changing the order status is to make things easy for subadmins, for whom I’ve created simple/limited UIs. The fewer controls they have to use, the better.
I see there’s this for detecting the change:
woocommerce_order_status_changed as in:
do_action( 'woocommerce_order_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
Now to do the role changes and use different email templates to send out different notifications of the reorder.