woocommerce_store_api_checkout_update_draft
Fires after a Store API checkout PATCH request has been validated and live customer/session state has been updated, before the response is returned.
Hook this action when an extension needs to observe live checkout state — e.g. abandoned-cart trackers, side-panel previews, conditional shipping or payment validators, or anything else that needs to react to every customer interaction with the form.
No WC_Order exists at this point under deferred draft order creation. Read checkout state from WC()->cart, WC()->customer, and the supplied $request, and persist any extension-owned state to WC()->session. To apply that state to the real order at place-order time, hook woocommerce_store_api_checkout_update_order_meta woocommerce_store_api_checkout_update_order_from_request both fire against the real, persisted order at POST exactly as they always have.
Usage
add_action( 'woocommerce_store_api_checkout_update_draft', 'wp_kama_woocommerce_store_api_checkout_update_draft_action' );
/**
* Function for `woocommerce_store_api_checkout_update_draft` action-hook.
*
* @param \WP_REST_Request $request The current PATCH request.
*
* @return void
*/
function wp_kama_woocommerce_store_api_checkout_update_draft_action( $request ){
// action...
}
- $request(\WP_REST_Request)
- The current PATCH request.
Changelog
| Since 10.8.0 | Introduced. |
Where the hook is called
do_action( 'woocommerce_store_api_checkout_update_draft', $request );