• Hi,
    I have read like every single topic about woocommerce but cannot find out how to add a minus button which decreases the quantity of a cart item (with ajax preferably) in the Woocommerce MiniCart.

    I did manage to add a button which increases the quantity using the woocommerce shortcode and via several other code samples. However, I cannot find how to decrease the quantity anywhere.

    There are multiple questions about this, none answered. Or I`m searhing in the wrong directory.

    However, can someone give me a code example on how to decrease cart`s quantity for a product out of the box? I already tried a custom php file with these lines of code:

    $cartKey = $_POST['cart_item_key'];
    $cartQty = $_POST['cart_item_qty'];
    
    global $woocommerce;
    echo $woocommerce->cart->set_quantity($cartKey,$cartQty);

    But calling this via AJAX post gives me an error (internal server error). I also tried add to cart with negative quantity, did not work either.

    What can I do? Thanks a lot I hope someone can help here!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter MarcelV91

    (@marcelv91)

    Thread Starter MarcelV91

    (@marcelv91)

    UPDATE:
    So I got a few things working using AJAX post. Cannot post to a PHP file directly, needed to add the page in WP and call that page with a custom template, which does the request handling.

    However, the cart does not get updated after the ajax post? So I have to do a refresh before I see any change.

    Ideas?

    Thread Starter MarcelV91

    (@marcelv91)

    Appearantly nobody knows how to do this, or nobody was willing to help.

    However, for future persons looking for this check my post on:

    for a working solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Anyone? Decrease quantity in mini cart woocommerce?’ is closed to new replies.