WC_Cart::restore_cart_item()publicWC 1.0

Restore a cart item.

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

Возвращает

true|false.

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

$WC_Cart = new WC_Cart();
$WC_Cart->restore_cart_item( $cart_item_key );
$cart_item_key(строка) (обязательный)
Cart item key to restore to the cart.

Код WC_Cart::restore_cart_item() WC 8.7.0

public function restore_cart_item( $cart_item_key ) {
	if ( isset( $this->removed_cart_contents[ $cart_item_key ] ) ) {
		$restore_item                                  = $this->removed_cart_contents[ $cart_item_key ];
		$this->cart_contents[ $cart_item_key ]         = $restore_item;
		$this->cart_contents[ $cart_item_key ]['data'] = wc_get_product( $restore_item['variation_id'] ? $restore_item['variation_id'] : $restore_item['product_id'] );

		do_action( 'woocommerce_restore_cart_item', $cart_item_key, $this );

		unset( $this->removed_cart_contents[ $cart_item_key ] );

		do_action( 'woocommerce_cart_item_restored', $cart_item_key, $this );

		return true;
	}
	return false;
}