woocommerce_before_delete_order хук-событиеWC 7.1.0

Fires immediately before an order is deleted from the database.

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

add_action( 'woocommerce_before_delete_order', 'wp_kama_woocommerce_before_delete_order_action', 10, 2 );

/**
 * Function for `woocommerce_before_delete_order` action-hook.
 * 
 * @param int      $order_id ID of the order about to be deleted.
 * @param WC_Order $order    Instance of the order that is about to be deleted.
 *
 * @return void
 */
function wp_kama_woocommerce_before_delete_order_action( $order_id, $order ){

	// action...
}
$order_id(int)
ID of the order about to be deleted.
$order(WC_Order)
Instance of the order that is about to be deleted.

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

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

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

OrdersTableDataStore::delete()
woocommerce_before_delete_order
Abstract_WC_Order_Data_Store_CPT::delete()
woocommerce_before_delete_order
woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php 2174
do_action( 'woocommerce_before_delete_order', $order_id, $order );
woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php 292
do_action( 'woocommerce_before_delete_order', $id, $order );

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

woocommerce/includes/class-wc-post-data.php 57
add_action( 'woocommerce_before_delete_order', array( __CLASS__, 'before_delete_order' ) );
woocommerce/includes/wc-order-functions.php 924
add_action( 'woocommerce_before_delete_order', 'wc_update_total_sales_counts' );
woocommerce/src/Admin/API/Reports/Orders/Stats/DataStore.php 116
add_action( 'woocommerce_before_delete_order', array( __CLASS__, 'delete_order' ) );