Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::delete_order_data_from_custom_order_tables()publicWC 1.0

Deletes order data from custom order tables.

Method of the class: OrdersTableDataStore{}

No Hooks.

Return

null. Nothing (null).

Usage

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->delete_order_data_from_custom_order_tables( $order_id );
$order_id(int) (required)
The order ID.

OrdersTableDataStore::delete_order_data_from_custom_order_tables() code WC 9.3.3

public function delete_order_data_from_custom_order_tables( $order_id ) {
	global $wpdb;
	$order_cache = wc_get_container()->get( OrderCache::class );

	// Delete COT-specific data.
	foreach ( $this->get_all_table_names() as $table ) {
		$wpdb->delete(
			$table,
			( self::get_orders_table_name() === $table )
				? array( 'id' => $order_id )
				: array( 'order_id' => $order_id ),
			array( '%d' )
		);
		$order_cache->remove( $order_id );
	}
}