Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::upshift_or_delete_child_orders
Set the parent id of child orders to the parent order's parent if the post type for the order is hierarchical, just delete the child orders otherwise.
Метод класса: OrdersTableDataStore{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->upshift_or_delete_child_orders( $order ): void;
- $order(WC_Abstract_Order) (обязательный)
- Order object.
Код OrdersTableDataStore::upshift_or_delete_child_orders() OrdersTableDataStore::upshift or delete child orders WC 11.3.0
private function upshift_or_delete_child_orders( $order ): void {
global $wpdb;
$order_table = self::get_orders_table_name();
$order_parent_id = $order->get_parent_id();
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$child_order_ids = $wpdb->get_col(
$wpdb->prepare(
"SELECT id FROM $order_table WHERE parent_order_id=%d",
$order->get_id()
)
);
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
if ( empty( $child_order_ids ) ) {
return;
}
if ( $this->legacy_proxy->call_function( 'is_post_type_hierarchical', $order->get_type() ) ) {
$wpdb->update(
$order_table,
array( 'parent_order_id' => $order_parent_id ),
array( 'parent_order_id' => $order->get_id() ),
array( '%d' ),
array( '%d' )
);
$this->clear_cached_data( $child_order_ids );
} else {
foreach ( $child_order_ids as $child_order_id ) {
$child_order = wc_get_order( $child_order_id );
if ( $child_order ) {
$child_order->delete( true );
}
}
}
}