How to achieve AddToCart Without quantity?
Collapse
X
-
I did not test what happens when you use AddtoCar without quantity, but looking at the code is seems pretty obvious why you cannot add an object with quantity=0
Do examine this piece of code from 'index.php'
Code:if(product_quantity > 0) { $.ajax({ url:"action.php", method:"POST", data:{product_id:product_id, product_name:product_name, product_price:product_price, product_quantity:product_quantity, action:action}, success:function(data) { load_cart_data(); alert("Item has been Added into Cart"); } }); } else { alert("lease Enter Number of Quantity"); }
-
Because you show an 'external link' to the code, I have copied the code to this site, so everyone can see what piece is handling the quantity stuff.. (If they are really interested in the complete code, they can follow the link (for as long as it exists...))
I did not change the code, because to /me your problem is SOO obvious (sorry), so I just copied relevant piece of code.Comment
-
aveeva:
Luuk has given you a very good answer, what have you done to actually troubleshoot your code?
I've set Luuk's post#4 as best answer
In the future please keep in mind that we normally require that the relevant part of the code be inserted and formatted using the [CODE/] format tool to be part of your thread for several reasons:
1) Such links are can be transient (as Luuk pointed out).
2) As many of us answer questions at work while on breaks or between project down times - the companies we work for often block code sites
3) Links like this can lead to malicious websites. I actually used a service that checks sites such that you linked to for threats before allowing this thread to stay.Comment
-
no - its not. The question was why a quantity of 0 wont work and Luuk did show the code that is responsible for that. Code is always doing as it is written - if you write a condition that checks for a value > 0 then it will fail of course when the value is 0. Simple as that.
Why anyone would like to add any kind of item to a cart with a quantity of 0 is another question and somehow beyond my imagination-capabilities though.Comment
Comment