16. E – Commerce Website PHP Tutorial – Quantity Control In Shopping Cart

www.developphp.com In this 16th video we will learn to allow the user to adjust item quantities inside of the PHP shopping cart. The E – Commerce Web Site we will be assembling is one in which all of the inventory is in a MySQL database and we offer a custom PHP cart for a unique shopping experience.

25 Comments

  • Hey there, very nice lesson series! I do have a weird problem though and I hoped you know what causes it: if I add a few items to the cart, at some point when I add an item that page is gonna load forever, and then after about 10 secs, there’s like a million of items added to the cart… Any ideas?
    Thanks 😀

  • Learning how do all this is more important than just getting the source code. I plan on watching this series over and over till I start understand how all this code works and produces your finished product.

    Thank you,

    Eric

  • @cockerspanielhome I agree man, the source code is the last thing I am waiting for. Understanding is what matter. That’s why I keep watching these videos over and over again until I get the logic of why is he doing it that way

  • @p0ker1sc00l
    Check to where the header-commands leed, And if you have put the sections in the same order as Adam did.
    Might help… If not check the variablenames for misspelling. Especially around the POST-Sector and the names of the form. That should make it.

  • Herro! So I was messing with the numbers in the quantity field. After only allowing 2 numbers in the quantity field, I found that if you put in a decimal number, php does it’s job and adjusts the price. So if I have an item that’s listed as $25.00 and I put .5 for the quantity, the new listed price becomes $12.50. How can we address this issue for the smart asses that will be browsing the site?

  • well i have made a drop down menu so they can only pick to change the number to max of 5 as i dont think i need it to be higher than that i will post it at develop php and zook i put the header code on the end of the new section 3 so just like we did before

  • how about adding a feature that allows you to update all items’ quantities with one (update or change) button, instead of updating individual items.

  • To check that $quantity is a number you can do :
    if (is_numeric($quantity) == false || $quantity < 0)
    {
    $quantity = 1;
    }
    $quantity = round ($quantity);
    I also added <0 so you cannot have a value of -1, and round so you cannot have 1.4

  • @adrian281990 thanks man, if the user happens to put a decimal number or even worst, a letter, we have to alleviate the quantity field.
    very useful. TNXs!!

  • @adrian281990 I tried using another method but I coded something wrong I guess because I was getting an error. So I popped in this code and no error…gotta love copy and paste. Thanks for this man. 🙂

  • The little fix to make sure the number they insert to change the quantity has no funny characters is in video part 17

  • Thanks for the great video! If you need help installing, configuring, or setting up zen cart, check out our channel for lots of Easy Help Zen Cart Tutorials:

  • code works great in MAMP but in my ISP iPage, with multiple items in the cart, only the quantity for the last item added can be changed. Changing the qty of items added earlier “hangs” the system before spitting out an error. Anyone have a fix for this? Been working on this ONE problem for a week, contacting iPage, trying different variations to Adam’s code, etc. with no luck. Please Help

Leave a Reply

Your email address will not be published. Required fields are marked *