WC_Cart_Session::set_updates_enabled_for_cart │ public static │ WC 11.2.0

Enables or disables session updates for a cart.

Method of the class: WC_Cart_Session{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Cart_Session::set_updates_enabled_for_cart( $cart, $enabled ): void;
$cart(WC_Cart) (required)
Cart object.
$enabled(true|false) (required)
Whether session updates should be enabled.

Changelog

Since 11.2.0 Introduced.

WC_Cart_Session::set_updates_enabled_for_cart() code WC 11.3.0

public static function set_updates_enabled_for_cart( WC_Cart $cart, $enabled ): void {
	$cart_id = spl_object_id( $cart );

	if ( $enabled ) {
		unset( self::$carts_with_disabled_updates[ $cart_id ] );
	} else {
		self::$carts_with_disabled_updates[ $cart_id ] = WeakReference::create( $cart );
	}
}