Automattic\WooCommerce\Internal\Caches

OrdersVersionStringInvalidator::did_customer_changeprivateWC 1.0

Check if the customer ID changed during the update.

Method of the class: OrdersVersionStringInvalidator{}

No Hooks.

Returns

true|false. True if customer changed.

Usage

// private - for code of main (parent) class only
$result = $this->did_customer_change( $order_id, $order ): bool;
$order_id(int) (required)
The order ID.
$order(WC_Order) (required)
The order object (after save).

OrdersVersionStringInvalidator::did_customer_change() code WC 10.7.0

private function did_customer_change( int $order_id, $order ): bool {
	if ( ! isset( $this->pre_save_customer_ids[ $order_id ] ) ) {
		return false;
	}

	$old_customer_id = $this->pre_save_customer_ids[ $order_id ];
	$new_customer_id = $order instanceof \WC_Order ? (int) $order->get_customer_id() : 0;

	return $old_customer_id !== $new_customer_id;
}