Hilly_2004 Posted April 6, 2006 Share Posted April 6, 2006 Hi guys,I really need your help because I am truly stumped. At the minute I have your basic shopping cart, items are added up and if you add multiple items it changes the quantity field to match and it looks like so...[a href=\"http://img96.imageshack.us/my.php?image=checkout14eq.jpg\" target=\"_blank\"][img src=\"http://img96.imageshack.us/img96/6223/checkout14eq.th.jpg\" border=\"0\" alt=\"IPB Image\" /][/a]However now I want to transfer [b]sizes[/b] into the checkout as well, I already have the form set up when you browse the item and it transfers a variable called $Size (containing values like 'Small', 'Medium' etc...) to the lib file where all the information submitted is then transformed into information for the checkout...[code]if(!isset($HTTP_SESSION_VARS['cart'])){ $HTTP_SESSION_VARS['cart']=array(); $HTTP_SESSION_VARS['items']=0; $HTTP_SESSION_VARS['total']="0.00";}if($add){ $itemID = $HTTP_POST_VARS['product']; $isFound = false; for($i =0; $i< count($HTTP_SESSION_VARS['cart']); $i++){ if($HTTP_SESSION_VARS['cart'][$i]['Item_ID'] == $itemID){ $isFound = $i; break; } } if($isFound !== false){ $HTTP_SESSION_VARS['cart'][$isFound]['quantity']++; }else{ $newItem = array(); $newItem['Item_ID'] = $itemID; $newItem['quantity'] = 1; array_push($HTTP_SESSION_VARS['cart'], $newItem); } $HTTP_SESSION_VARS['items']++; // array_push($HTTP_SESSION_VARS['cart'], $product); $HTTP_SESSION_VARS['total']+=$price; }[/code] However the way my cart is set up is that it doesn't show the multiple items of the same type seperately instead it puts a 2 in the quantity field...[a href=\"http://img96.imageshack.us/my.php?image=checkout20xd.jpg\" target=\"_blank\"][img src=\"http://img96.imageshack.us/img96/7765/checkout20xd.th.jpg\" border=\"0\" alt=\"IPB Image\" /][/a]...firstly I need to change that and then I need to figure out a way of creating it so that it looks like this:[a href=\"http://img96.imageshack.us/my.php?image=checkout35si.jpg\" target=\"_blank\"][img src=\"http://img96.imageshack.us/img96/9720/checkout35si.th.jpg\" border=\"0\" alt=\"IPB Image\" /][/a]My checkout code looks like this:[code] $subtotal = 0; for($i=0; $i<count($myCart); $i++){ $query="SELECT * FROM Items WHERE Item_ID = '".$myCart[$i]['Item_ID']."'"; $result=mysql_query($query, $conn); $basketItems=mysql_fetch_array($result); $subtotal+=($basketItems['UK_Price']*$myCart[$i]['quantity']);//ITEM NAMEecho $basketItems['Item_Name'];//QUANTITYecho $myCart[$i]['quantity'];//PRICE (exc VAT)echo money_format($fmt, ($basketItems['UK_Price']*$myCart[$i]['quantity']));[/code] This is quite a long winded request, but as much or as little help would be great. Any further information then please just ask.P.S. Some of the details on the screenshots are wrong, but you get the jist from the explanations. Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/ Share on other sites More sharing options...
Hilly_2004 Posted April 6, 2006 Author Share Posted April 6, 2006 *Bump before it goes off the page* Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-24629 Share on other sites More sharing options...
Hilly_2004 Posted April 8, 2006 Author Share Posted April 8, 2006 [img src=\"http://www.phpfreaks.com/forums/style_images/1/folder_post_icons/icon9.gif\" border=\"0\" alt=\"IPB Image\" /] Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-24943 Share on other sites More sharing options...
ToonMariner Posted April 8, 2006 Share Posted April 8, 2006 you will have to add another element to your 'cart' array to store the new data. You may also have to add to the script that displays the cart info so that it too displays the new information.You have the code in place to insert new elements to the array so just use that and make sure the data is passed from the form correctly. Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-24944 Share on other sites More sharing options...
Hilly_2004 Posted April 8, 2006 Author Share Posted April 8, 2006 So do you suggest adding something like this after...if($HTTP_SESSION_VARS['cart'][$i]['Item_ID'] == $itemID)&& ($HTTP_SESSION_VARS['cart'][$i]['Size'] == $size) {However that won't validate will it, so how can I get an extra field into the cart session? Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-25031 Share on other sites More sharing options...
Hilly_2004 Posted April 10, 2006 Author Share Posted April 10, 2006 [img src=\"http://www.phpfreaks.com/forums/style_images/1/folder_post_icons/icon9.gif\" border=\"0\" alt=\"IPB Image\" /] Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-25484 Share on other sites More sharing options...
Hilly_2004 Posted April 10, 2006 Author Share Posted April 10, 2006 lol...Im going to keep bumping until some sod replies lol :) Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-25685 Share on other sites More sharing options...
Hilly_2004 Posted April 13, 2006 Author Share Posted April 13, 2006 *Sigh* Please? Anyone? Getting desperate now. Quote Link to comment https://forums.phpfreaks.com/topic/6703-transferring-sizes-into-my-shopping-cart/#findComment-26436 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.