Jump to content

Shopping Cart w/ Jon Lebensold - I'm stuck on vid 6 & 7


Cory Duchesne

Recommended Posts

Hello,

 

I recently bought the vid tutorial on making a shopping cart, hosted by Jon Lebensold.

 

I feel like I have a decent grasp on what is being demonstrated, however, at the end of vid 7, my Shopping Cart is not working properly, but it seems like I'm doing everything Jon has done.

 

The problem I'm having is really difficult for me to explain, so I uploaded my work to my domain, just so I could show you guys what's happening.

 

So please take a look:

 

http://corewebworks.com/test_php/html/index.php

 

I realize SESSION prevents the shopping cart from disappearing between one page request and another, and it seems to be working to a slight degree.

 

However, something is really wrong, but I can't put a finger on it, and the result is extremely flawed.

 

I encourage you to see for yourself by visiting the link I laid above.

 

Thanks! :)

 

Just let me know what code you want to see, and I'll try to post it.

Link to comment
Share on other sites

I haven't personally worked through the tutorial, but here are a couple observations:

 

-- Looks like the "Add to cart" page has the error that is causing things to not work correctly. Could you post the PHP code to that, and we can take a look?

 

-- The third link on http://corewebworks.com/test_php/html/index.php on adds a "test" product to the cart, rather than a "mango" item. Is that correct?

 

-- On the add to cart page, you have "$ amount" under the "Amount" heading. That could be a case where either

a) there isn't supposed to be a space between the two

B) or, if "$" is supposed to appear before the amount, perhaps "amount" is supposed to be a variable ("$amount") rather than just text?

Link to comment
Share on other sites

Hi Falken :)

 

Thanks for the response.

 

I haven't personally worked through the tutorial, but here are a couple observations:

 

-- Looks like the "Add to cart" page has the error that is causing things to not work correctly. Could you post the PHP code to that, and we can take a look?

 

sure, here's the code:

 

>
<?php
require_once '../functions/functions.php';


$shopping_cart = get_shopping_cart();

echo render_header('Absolute Music Notation: Catalogue');
?>

<?php

   $product_id = $_REQUEST['id'];

   if (product_exists($product_id))
{
   $shopping_cart->AddItem($product_id);    
}    



?>

</pre>
<table>
       Product ID

       Quantity

       Amount

       $product_id

       $quantity

       $ amount
</table>
<br><br><?php<br>   set_shopping_cart($shopping_cart);<br><br>?><br><br><br><?php <br><br>echo render_footer ('footer');<br><br>?&gt

 

 

-- The third link on http://corewebworks.com/test_php/html/index.php on adds a "test" product to the cart, rather than a "mango" item. Is that correct?

 

yeah, thats ok, I just filled a bunch of dummy text into the xml file. but you're right, instead of test it should be mango. But that doesn't fix the problem.

 

-- On the add to cart page, you have "$ amount" under the "Amount" heading. That could be a case where either

a) there isn't supposed to be a space between the two

B) or, if "$" is supposed to appear before the amount, perhaps "amount" is supposed to be a variable ("$amount") rather than just text?

 

Actually, since I'm only on vid 7, this is actually the way it's supposed to look, based on what Jon has done at the end of vid 7. He has $ ammunt, too.

Link to comment
Share on other sites

This is a bit of a guess on my part, but take a look at this section of code and make sure it follows the tutorial exactly:

 

foreach ($shopping_cart->GetItems() as $products_id)

   {
   echo render_shopping_cart_row($shopping_cart , $product_id , $line_item_counter);    
   $line_item_counter++;
   }

 

This line "foreach ($shopping_cart->GetItems() as $products_id)" uses $products_id is used, but within the loop "$product_id" is used (no "s"). Perhaps they are intended to be the same variable, and either they both need an "s", or it the extra "s" needs to be removed?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...