Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
HandlerRegistry::get_product_ids_from_order
Get product IDs from an order.
Метод класса: HandlerRegistry{}
Хуков нет.
Возвращает
Массив
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_product_ids_from_order( $order_id );
- $order_id(int) (обязательный)
- The order ID.
Код HandlerRegistry::get_product_ids_from_order() HandlerRegistry::get product ids from order WC 10.8.1
private function get_product_ids_from_order( $order_id ) {
$product_references = array();
if ( empty( $order_id ) ) {
return $product_references;
}
$order = wc_get_order( $order_id );
if ( $order ) {
$product_references = array_filter(
array_map(
function ( $item ) {
return $item->get_product_id();
},
$order->get_items( OrderItemType::LINE_ITEM )
)
);
}
return $product_references;
}