PHP doesnt add quantity to shopping cart - always adds 1 item (1 Viewer)

KevinSlater

Registered User.
Local time
Today, 12:55
Joined
Aug 5, 2005
Messages
249
Hi,

I am using RomanCart as the shopping cart system within our website. On our website at present on the Shop page there is a selection of products and a "add to basket" button, & a quantity drop down list next to each product. When the user selects a product quantity from a drop down list and then clicks on the "add to basket" buttons it loads the shopping cart page which should add the appropiate product the customer selected along with the product quantity to the shopping basket, currently it adds the correct product correctly however it only ever adds just the one product regardless of the quantity selected.

I have this code on my html shop page for the "Add to Basket" button
form action=http://www.mywebsite.com/Shop/addtocart.php method=get>
£2.99 Quantity<select name=quantity><option>1<option>2<option>3<option>4<option>5<option>6<option>7<option>8<option>9<option>10</select>
<input type=submit value='Add to Basket'>
<input name="product" type="hidden" value="Product1"/>
</form>

Then the addtocart.php page has this to add the product (within an iframe)
<iframe src="http://www.romancart.com/cart.asp?storeid=1234&itemcode=<?php echo $_GET['product']?>"&quantity=<?php echo $_GET['quantity']?>" height="400" width="600" frameborder="0" scrolling="Yes"> IFrame. </iframe>

Im thinking maybe my php code is incorrect but not sure whats wrong?, ive also tried changing the method=post instead of get also on the shop.html page but that has not helped.

Any suggestions?

Kevin
 

DanG

Registered User.
Local time
Today, 04:55
Joined
Nov 4, 2004
Messages
477
I would start with the HTML myself. Your select structure is unlike anything I've seen before.
Structure should be:
Code:
<select>
  <option value ="volvo">Volvo</option>
  <option value ="saab">Saab</option>
  <option value ="opel">Opel</option>
  <option value ="audi">Audi</option>
</select>

If it is passing at least one numer then you kind of know the php code is OK (maybe). You should make sure that the correct number is being presented to the PHP and that is done by your HTML.

HTH
 

KevinSlater

Registered User.
Local time
Today, 12:55
Joined
Aug 5, 2005
Messages
249
Hi,

ive found out what the problem is. I had a " to many in the wrong place in the addtocart.php page. ie ]?>"&quantity should be ]?>&quantity

code below works:

<iframe src="http://www.romancart.com/cart.asp?storeid=1234&itemcode=<?php echo $_GET['product']?>&quantity=<?php echo $_GET['quantity']?>" height="400" width="600" frameborder="0" scrolling="Yes"> IFrame. </iframe>

Thanks for comments about the option selection in the HTML, ill review this although it works fine now.

Kevin
 

Users who are viewing this thread

Top Bottom