October 14, 201115 yr apprently this: <?php // put this php code at the very top of your page, before anything else gets displayed. if(!session_id())session_start(); $cart_products = isset($_SESSION['_simpleshop_cart_products']) ? $_SESSION['_simpleshop_cart_products'] : array(); $cart_sub_total = 0; $cart_total = 0; $cart_shipping = 0; foreach($cart_products as $product_id ?> $product){ $quantity = max(1,(int)$product['quantity']); $product_total = $product['price'] * $quantity; $cart_sub_total += $product_total; if(isset($product['product_settings']['shipping']) && $product['product_settings']['shipping']>0){ $cart_shipping += $product['product_settings']['shipping']; } } $cart_total = $cart_sub_total + $cart_shipping; ?> then placing this code below will show the cart total of the php shopping system im using. echo $cart_total; however if you copy and paste the top into a text editor the author has made a big mistake on line 7 i think, reckon you know how to amend this line, to make it work?
October 14, 201115 yr Looks like line 7 should read: foreach($cart_products as $product){ i.e. remove the '$product_id ?>' Edited October 14, 201115 yr by mrchristoph
October 14, 201115 yr The author might also of meant it to be foreach($cart_products as product_id => $product) The ?> is saying stop executing PHP
October 14, 201115 yr Author The author might also of meant it to be foreach($cart_products as product_id => $product) The ?> is saying stop executing PHP Thanks for pointing that out foreach($cart_products as $product_id => $product){ ? Threw me an error Looks like line 7 should read: foreach($cart_products as $product){ i.e. remove the '$product_id ?>' Actually works wehey! cheers
Create an account or sign in to comment