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

DataStore::sync_order()public staticWC 1.0

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

Method of the class: DataStore{}

No Hooks.

Return

Int|true|false. 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 7.3.0

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

	$order = wc_get_order( $post_id );
	if ( ! $order ) {
		return -1;
	}

	return self::update( $order );
}