Automattic\WooCommerce\Admin\API\Reports\Orders\Stats
DataStore::delete_order
Deletes the order stats when an order is deleted.
Method of the class: DataStore{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$result = DataStore::delete_order( $post_id );
- $post_id(int) (required)
- Post ID.
DataStore::delete_order() DataStore::delete order code WC 10.7.0
public static function delete_order( $post_id ) {
global $wpdb;
$order_id = (int) $post_id;
if ( ! OrderUtil::is_order( $post_id, array( 'shop_order', 'shop_order_refund' ) ) ) {
return;
}
// Retrieve customer details before the order is deleted.
$order = wc_get_order( $order_id );
$customer_id = absint( CustomersDataStore::get_existing_customer_id_from_order( $order ) );
// Delete the order.
$wpdb->delete( self::get_db_table_name(), array( 'order_id' => $order_id ) );
/**
* Fires when orders stats are deleted.
*
* @param int $order_id Order ID.
* @param int $customer_id Customer ID.
*
* @since 4.0.0
*/
do_action( 'woocommerce_analytics_delete_order_stats', $order_id, $customer_id );
ReportsCache::invalidate();
}