Can't adjust qty or remove first item in the cart

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

I tried to experiment with it on the site, but it won't add any items to the cart.
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

That is strange...I just tried the site and it was adding items to the cart. Do I maybe have a few bugs in the cart code?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

Looks like you're using $_POST when you're supposed to be using $_GET in your code to add items to the cart.
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

Ok, so now when i add items to the cart it does the following (after changing $_POST to $GET):

It adds the first item with a quantity of 1, the second with a quantity of 3, the third with a quantity of 3, the fourth with a quantity of 3. When I try to adjust the quantity of the second item, the quantity of the first item goes to 5. When the quantity is set to 0 it will remove the item, except the first item in the cart.

So, it's not adjusting the quantities properly or putting the correct quanitity in the cart when the item is added.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

Still won't add items to the cart. Go here:

http://coppercreekbathandbody.ca/cart.p ... scent=0032

Despite multiple refreshes, it states that the cart is empty.
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

Ok. I'm testing it on the localhost right now. that is where I'm getting those problems. I haven't reuploaded the recent changes to the website yet.
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

Ok, so I uploaded the changes...it seems to add products to the cart without any problems, for me anyway. It still doesn't want to adjust the first item in the cart though.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

Alright, now items are added to the cart, but changing quantities doesn't work for any products, not just the first one. Change the submit link to a submit button (<input> with type "submit").
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

That's weird because I can change the quantities of all items except the first. Is there another option, I'm trying to avoid the ugly submit button look. lol.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

If you want it to look better, style it with CSS. Just don't go down the Javascript road in this case.
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

I have my update button like this:

Code: Select all

<input class=updateButton name=updateButton value=Update type=submit>
When I click on the first item, it still won't adjust the quantity. It adjusts the quantity of the other items.

I haven't uploaded it to the webpage yet. I'm testing it in localhost.

When I click on the "update" button for the first item in the cart, the url turns to:
http://localhost/CopperCreek/cart.php?q ... ton=Update
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

What does the URL say for the rest?
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

When I adjust the rest the url displays:

http://localhost/CopperCreek/cart.php
mrzebra
Forum Commoner
Posts: 37
Joined: Tue Feb 22, 2011 10:30 pm

Re: Can't adjust qty or remove first item in the cart

Post by mrzebra »

So I did some playing around and if I change your code to adjust the item or remove the item from the cart from $_POST to $_GET, it will remove and change the quantity of the first item in the cart but not the other items. If I leave it as $_POST, it changes and removes all the items except the first item in the cart.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Can't adjust qty or remove first item in the cart

Post by Jonah Bron »

It's a problem with the Javascript. Have you replaced the link with a submit button? It's still a link on the site.
Post Reply