woocommerce_create_order
Gives plugins an opportunity to create a new order themselves.
Usage
add_filter( 'woocommerce_create_order', 'wp_kama_woocommerce_create_order_filter', 10, 2 );
/**
* Function for `woocommerce_create_order` filter-hook.
*
* @param int|null $order_id Can be set to an order ID to short-circuit the default order creation process.
* @param WC_Checkout $checkout Reference to the current WC_Checkout instance.
*
* @return int|null
*/
function wp_kama_woocommerce_create_order_filter( $order_id, $checkout ){
// filter...
return $order_id;
}
- $order_id(int|null)
- Can be set to an order ID to short-circuit the default order creation process.
- $checkout(WC_Checkout)
- Reference to the current WC_Checkout instance.
Changelog
| Since 3.0.0 | Introduced. |
| Since 3.0.0 | or earlier |
Where the hook is called
woocommerce_create_order
woocommerce/includes/class-wc-checkout.php 384
$order_id = apply_filters( 'woocommerce_create_order', null, $this );
Where the hook is used in WooCommerce
woocommerce/src/Internal/Admin/Schedulers/OrdersScheduler.php 93
add_filter( 'woocommerce_create_order', array( __CLASS__, 'possibly_schedule_import' ) );