I writing a little script to count the total number of items in a shopping basket. It's fairly straight forward counting the amount of different items, but the problem I'm having is counting the items with more than 1 as the quantity. The code below generates the go to checkout button, but I'm also using it to get the number of items in the basket.
count($cartContents) - Gets number of different itemsCode:for($i=0; $i < count($cartContents); $i++){ $val = $i + 1; $counting = count($cartContents); $items .= " <input type='hidden' name='item_name_$val' value='". $cartContents[$i][1] ."' /> <input type='hidden' name='amount_$val' value='". $cartContents[$i][3] ."' /> <input type='hidden' name='currency_code' value='GBP' /> <input type='hidden' name='quantity_$val' value = '" . $cartContents[$i][2] . "' /> "; }
$cartContents[$i][2] - Gets the quantity of each item
Can anyone help me with the code to get the total number of items please?





Bookmarks