Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

DataStore::delete_order()public staticWC 1.0

Deletes the order stats when an order is deleted.

Метод класса: DataStore{}

Хуки из метода

Возвращает

null. Ничего (null).

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

$result = DataStore::delete_order( $post_id );
$post_id(int) (обязательный)
Post ID.

Код DataStore::delete_order() WC 8.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();
}