Cory Duchesne Posted September 23, 2009 Report Share Posted September 23, 2009 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 23, 2009 Report Share Posted September 23, 2009 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 or, if "$" is supposed to appear before the amount, perhaps "amount" is supposed to be a variable ("$amount") rather than just text? Quote Link to comment Share on other sites More sharing options...
Cory Duchesne Posted September 23, 2009 Author Report Share Posted September 23, 2009 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>?> -- 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 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 23, 2009 Report Share Posted September 23, 2009 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? Quote Link to comment Share on other sites More sharing options...
Cory Duchesne Posted September 23, 2009 Author Report Share Posted September 23, 2009 (edited) Yes, it worked! I've been driving myself crazy all day trying to find the problem, I can't believe I overlooked that. Thank you so much, Falken, it's such a relief to get this resolved. Edited September 23, 2009 by Cory Duchesne Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 23, 2009 Report Share Posted September 23, 2009 Great! That's one of the toughest types of programming bugs to work out -- a logical error rather than a syntax error. There are no "real" bugs in the code, so PHP doesn't show any errors, but the program performs incorrectly. 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.