Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

DataStore::sync_order │ public static │ WC 1.0

Add order information to the lookup table when orders are created or modified.

Method of the class: DataStore{}

No Hooks.

Returns

int|bool. Returns -1 if order won't be processed, or a boolean indicating processing success.

Usage

$result = DataStore::sync_order( $post_id );
$post_id(int) (required)
Post ID.

DataStore::sync_order() code WC 11.2.2

public static function sync_order( $post_id ) {
	if ( ! OrderUtil::is_order( $post_id, array( 'shop_order', 'shop_order_refund' ) ) ) {
		return -1;
	}

	/**
	 * The order instance to be synchronized.
	 *
	 * @var false|Order|OrderRefund $order Order instance (Override classes registered via OrdersScheduler::init()).
	 */
	$order = wc_get_order( $post_id );
	if ( ! $order ) {
		return -1;
	}

	return self::update( $order );
}