WC_Cart::restore_cart_item PHP Method

restore_cart_item() public method

Restore a cart item.
public restore_cart_item ( string $cart_item_key ) : boolean
$cart_item_key string
return boolean
    public function restore_cart_item($cart_item_key)
    {
        if (isset($this->removed_cart_contents[$cart_item_key])) {
            $this->cart_contents[$cart_item_key] = $this->removed_cart_contents[$cart_item_key];
            $this->cart_contents[$cart_item_key]['data'] = wc_get_product($this->cart_contents[$cart_item_key]['variation_id'] ? $this->cart_contents[$cart_item_key]['variation_id'] : $this->cart_contents[$cart_item_key]['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);
            $this->calculate_totals();
            return true;
        }
        return false;
    }
WC_Cart