Jump to content

Recommended Posts

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...