richardhsu001 Posted January 27, 2009 Share Posted January 27, 2009 Hi, I have seen that most shopping cart program allows a shopper to pick up one item at a time from a list of items, then goes back the list to put another one in the shopping cart, etc. I am interested in finding out if I can use PHP to first display a list of items as below to a customer: ITEM QTY A 0 B 0 C 0 D 0 and then have him/her to change the quantity value for multiple items and then add all non-zero qty items to the shopping cart together with one " add to shopping cart" button. Please advise...I really appreciate to know if this is doable. If so, any script coding will be appreciated. Link to comment https://forums.phpfreaks.com/topic/142711-shopping-cart-program-for-multiple-item-pick/ Share on other sites More sharing options...
premiso Posted January 28, 2009 Share Posted January 28, 2009 Very possible, here is an example: <input type="text" size="4" name="item[A]" /> <input type="text" size="4" name="item[b]" /> <input type="text" size="4" name="item[C]" /> Of course I am just showing the simple version, you need to incorperate that to have it dynamic. To access it you would do: <?php if (isset($_POST)) { $item = isset($_POST['item'])?$_POST['item']:array(); foreach ($item as $itemName => $qty) { if ($qty > 0) { // your coding here... } } } ?> Link to comment https://forums.phpfreaks.com/topic/142711-shopping-cart-program-for-multiple-item-pick/#findComment-748083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.