eechukwu Posted June 21, 2012 Report Share Posted June 21, 2012 When i add an item to the shopping cart..the item does not show instead these is what i see : View Store View Cart Clear Cart Product Id Quantity Amount $product_id $quantity $ amount $product_id $quantity $ amount $product_id $quantity $ amount <?php require_once '../functions/functions.php'; //call the shopping cart function $shopping_cart = get_shopping_cart(); echo render_header(); $product_id = $_REQUEST['id']; if(product_exists($product_id)) { $shopping_cart->AddItem($product_id); } ?> <table class ='shoppingCart'> <tr> <th>Product Id</th> <th>Quantity</th> <th>Amount</th> </tr> <?php //create a local variable called line Item counter $line_item_counter = 1; foreach ($shopping_cart->GetItems() as $product_id) { echo render_shopping_cart_row($shopping_cart, $product_id,$line_item_counter); $line_item_counter++; } function render_shopping_cart_row($shopping_cart, $product_id,$line_item_counter) { $quantity = $shopping_cart->GetItemQuantity($product_id); $output = '<tr> <td>$product_id</td> <td>$quantity</td> <td>$ amount</td> </tr>'; return $output; } ?> </table> <?php set_shopping_cart($shopping_cart); echo render_footer(); ?> Thats my addToCart code. Every other thing worked perfectly well till here..(Lesson7)..Thanks Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 21, 2012 Report Share Posted June 21, 2012 In these lines: $output = '<tr> <td>$product_id</td> <td>$quantity</td> <td>$ amount</td> </tr>'; You need to be using double quotes: " not single quotes: ' Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.