woocommerce_new_order хук-событиеWC 2.7.0

Fires when a new order is created.

Использование

add_action( 'woocommerce_new_order', 'wp_kama_woocommerce_new_order_action', 10, 2 );

/**
 * Function for `woocommerce_new_order` action-hook.
 * 
 * @param int       $order_id Order ID.
 * @param \WC_Order $order    Order object.
 *
 * @return void
 */
function wp_kama_woocommerce_new_order_action( $order_id, $order ){

	// action...
}
$order_id(int)
Order ID.
$order(\WC_Order)
Order object.

Список изменений

С версии 2.7.0 Введена.

Где вызывается хук

OrdersTableDataStore::create()
woocommerce_new_order
WC_Order_Data_Store_CPT::create()
woocommerce_new_order
WC_Order_Data_Store_CPT::update()
woocommerce_new_order
WC_API_Orders::create_order()
woocommerce_new_order
woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php 1992
do_action( 'woocommerce_new_order', $order->get_id(), $order );
woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php 103
do_action( 'woocommerce_new_order', $order->get_id(), $order );
woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php 194
do_action( 'woocommerce_new_order', $order->get_id(), $order );
woocommerce/includes/legacy/api/v3/class-wc-api-orders.php 505
do_action( 'woocommerce_new_order', $order->get_id() );
woocommerce/includes/legacy/api/v2/class-wc-api-orders.php 465
do_action( 'woocommerce_new_order', $order->get_id() );

Где используется хук в WooCommerce

woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php 71
self::add_action( 'woocommerce_new_order', array( $this, 'handle_updated_order' ), 100 );