K
K
kamisarlapsha2019-01-23 02:33:46
JavaScript
kamisarlapsha, 2019-01-23 02:33:46

How to remove an item from an OpenCart 2.3 cart?

Hey! I made buttons for the quantity of goods in the popup cart. But the cart.add function works, but cart.remove does not (nothing happens when it is pressed). As a result, it turns out that the quantity of goods can only be added.
In file /common/cart.tpl

<div class="product-count">
                <input id="quantity" class="quant" type="text" name="quantity" value="<?php echo $product['quantity']; ?>" id="quantity"/>
                <div class="count-arrows">
                    <button onclick="cart.add('<?php echo $product['product_id']; ?>');" class="count-up"></button>
                    <button onclick="cart.remove('<?php echo $product['product_id']; ?>');" class="count-down"></button>
                </div>
                </div>

How it is possible to correct it? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2019-01-23
@kamisarlapsha

1. Instead of <?php echo $product['cart_id']; ?> - <?php echo $product['product_id']; ?>
These are different things.
2. cart.remove - a function to remove an item from the cart, not to reduce the quantity
3. You need the cart.update function Cart_id
should be passed to the first variable, and the new quantity to the second.
Try something like:
4. Adding quantity, you should also rewrite it in the same way. It will work for you until you add a product with options.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question