Jump to content

eechukwu

New Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by eechukwu

  1. 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 New...