Automattic\WooCommerce\Internal\Admin\Schedulers

OrdersScheduler::import()public staticWC 1.0

Imports a single order or refund to update lookup tables for. If an error is encountered in one of the updates, a retry action is scheduled.

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

Хуков нет.

Возвращает

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

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

$result = OrdersScheduler::import( $order_id );
$order_id(int) (обязательный)
Order or refund ID.

Код OrdersScheduler::import() WC 8.7.0

public static function import( $order_id ) {
	$order = wc_get_order( $order_id );

	// If the order isn't found for some reason, skip the sync.
	if ( ! $order ) {
		return;
	}

	$type = $order->get_type();

	// If the order isn't the right type, skip sync.
	if ( 'shop_order' !== $type && 'shop_order_refund' !== $type ) {
		return;
	}

	// If the order has no id or date created, skip sync.
	if ( ! $order->get_id() || ! $order->get_date_created() ) {
		return;
	}

	$results = array(
		OrdersStatsDataStore::sync_order( $order_id ),
		ProductsDataStore::sync_order_products( $order_id ),
		CouponsDataStore::sync_order_coupons( $order_id ),
		TaxesDataStore::sync_order_taxes( $order_id ),
		CustomersDataStore::sync_order_customer( $order_id ),
	);

	if ( 'shop_order' === $type ) {
		$order_refunds = $order->get_refunds();

		foreach ( $order_refunds as $refund ) {
			OrdersStatsDataStore::sync_order( $refund->get_id() );
		}
	}

	ReportsCache::invalidate();
}