WooCommerce Add to Cart Trigger

Graphic46

Active member
Oct 2, 2018
401
88
28
Hi Forum!

How can I automatically reduce the quantity value back to one when added to the cart?

For example, you can look at this page. https://peakshops.fuelthemes.net/peakshops-organicmarket/product/cropped-faux-leather-jacket/

i change quantity to ten and i click add to cart button.
Then i want to only one. i click add to cart. again its will add to ten in my cart.
i dont want to it. because speed is important for the customer. how do I get it to fall automatically? how can i solve this with javascript, jquery or function.php?

I realy need this. Thanks.
 

Graphic46

Active member
Oct 2, 2018
401
88
28
Thnks bro. but dont want to it. customer can add as many products as he wants. I just want the amount to automatically drop to the 1 value when click add to cart button.
 

madroots

Active member
Jan 23, 2020
215
127
43
Not sure If I understand you correctly. If I add to card 10x tomatoes, I will get 10x tomatoes in the card.

Do you want to reset quantity from anything to 1 once the quantity is added to cart?

Why would you want this? If customer select quantity he needs, he probable doesn't care whats the state of a quantity field. If he change his mind about the quantity, he can easily add or remove items from within his cart.

Explain in more detail please because this doesn't make sense to me. Cheers
 
  • Like
Reactions: samiraja

samiraja

Member
Nov 20, 2018
33
11
8
35
Tamilnadu, India
www.itangle.co.in
Not sure If I understand you correctly. If I add to card 10x tomatoes, I will get 10x tomatoes in the card.

Do you want to reset quantity from anything to 1 once the quantity is added to cart?

Why would you want this? If customer select quantity he needs, he probable doesn't care whats the state of a quantity field. If he change his mind about the quantity, he can easily add or remove items from within his cart.

Explain in more detail please because this doesn't make sense to me. Cheers
Yeah me too
 

Saint Gabriel

Well-known member
Jan 3, 2020
2,998
3,049
113
Not sure If I understand you correctly. If I add to card 10x tomatoes, I will get 10x tomatoes in the card.

Do you want to reset quantity from anything to 1 once the quantity is added to cart?

Why would you want this? If customer select quantity he needs, he probable doesn't care whats the state of a quantity field. If he change his mind about the quantity, he can easily add or remove items from within his cart.

Explain in more detail please because this doesn't make sense to me. Cheers
He's clearly confused.
 

Graphic46

Active member
Oct 2, 2018
401
88
28
This my quantity selector and add to cart button.

HTML:
<form action="?add-to-cart=90" class="cart" method="post" enctype="multipart/form-data">
<div class="quantity">
        <div class="qty-box">
            <span class="decrease"></span>
            <input type="number" id="quantity_5edb532feef89 sw-qua" class="input-text qty text" step="1" min="0" max="33" name="quantity" value="1" title="Qty" size="4" placeholder="" inputmode="numeric">
             <span class="increase"></span>
        </div>
    </div>
 <button type="submit" id="sw_add_to_cart" data-quantity="1" data-title="Pampers Swaddlerss" data-product_id="90" class="button alt ajax_add_to_cart add_to_cart_button product_type_simple">Add to cart</button></form>




This is my jquery script.

JavaScript:
        $("form.cart").on("click", "sw_add_to_cart", function() {
            $("input.sw-qua").val( "1" ).change();
        });



but did not work. how to run correctly?
 

Graphic46

Active member
Oct 2, 2018
401
88
28
I want each addition to the shopping cart to start at 1. Not where it left off. ok? it's simple. if u add to cart 10x tomato. and i add want to only 1 more without the need to go to the cart page.

that's actually what I want to do = https://www.willys.se/
but it seems difficult.
so my solution will do my job for now.
 

Forum statistics

Threads
69,225
Messages
908,427
Members
237,006
Latest member
choky10

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu