items = $this->getItemsByOrders(); } protected function getItemsByOrders() { $ordersIds = isset($this->data[static::IMPORT_ITEMS_IDS_PARAM]) ? $this->data[static::IMPORT_ITEMS_IDS_PARAM] : null; if (!$ordersIds) { return array(); } $orders = array(); foreach ($ordersIds as $orderId) { $orderPost = get_post($orderId) ?: new \WP_Post((object) array( 'ID' => $orderId, 'post_type' => 'shop_order', )); $orders[] = $orderPost; } return $orders; } }