Deprecated: Function create_function() is deprecated in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/plugins/wp-automatic/wp-automatic.php on line 70
#3 Shopping Cart With Checkout System Using Bootstrap 4, PHP, MySQLi & Ajax | Adding Product to Cart | D4mations.com
  • Thursday , 3 December 2020

#3 Shopping Cart With Checkout System Using Bootstrap 4, PHP, MySQLi & Ajax | Adding Product to Cart

Code Canyon
https://i.ytimg.com/vi/9a5wRuSvJWQ/hqdefault.jpg



Hello friends! In this video tutorial series you will learn how to make a shopping cart with checkout system using Bootstarp 4, PHP, MySQLi (Prepared Statement OOP) and jQuery Ajax.

This is the 3rd video of this series in which I’m showing you how to add product in cart when we click on add to cart button. And I’m also showing you how to update cart counter number dynamically using Ajax and PHP.

Source Code : https://dcodemania.com/post/shopping-cart-with-checkout-system-php-mysqli-ajax

Full Playlist of this project : https://www.youtube.com/playlist?list=PL6u82dzQtlfsQoq15__a6oRLLwvkhGu43

#shoping_cart_php_ajax
#cart_system_php_mysqli
#checkout_system_php_mysqli

If you like my works and my video tutorials then you can donate me some amount. You can donate through these links :

Paypal : https://www.paypal.me/wolfmania

Instamojo (Credit/Debit Card & UPI) : https://www.instamojo.com/@wolfmania

Thanks for watching this video. If you like this video then hit like button, share this video, And Subscribe my Channel. Also like my Facebook page for latest updates.

♥ Facebook Page – https://www.facebook.com/dcodemania
♥ Myself On FB – https://www.facebook.com/sahil4rock
♥ Instagram – https://www.instagram.com/sahil4rock
♥ Twitter – https://twitter.com/dcodemania

Original source

3d Ocean

Related Posts

50 Comments

  1. Djatmiko Ufn
    November 21, 2020 at 22:18

    Problem found: product_code on table cart the are not unique number appear but characters value <br /><b> others data are correct. Here is result :
    Huawei10 pro
    75000 image/huawei_mate10_pro.jpg 1 75000 <br /><b>
    Problem has been solved. Thanks a lot of.

  2. 羊祺
    November 21, 2020 at 22:18

    Finally my code is working, thank you sir!

  3. Aditya Meena
    November 21, 2020 at 22:18

    Sir when I clicked on Add to cart button product does not added to cart or database or cart number I type code 10times as you type in video so sir plz provide source code of tutorial & help your subscriber

  4. Sankalp Vyas
    November 21, 2020 at 22:18

    Man, your code isn't working! I'm not able to enter the data into the database! Nothing happens when i click the add to cart button! I watched the video 3 times and typed the code 3 times, but nothing happens

  5. Dean Ross
    November 21, 2020 at 22:18

    I have watched this video 3 -4 times and went through both action.php and index.php but I can't seem to get it to add to the cart database after clicking add to cart button. this my line of code, as well I am not getting a return message for success or not item has been added. Please get back to me
    from Action.php
    <?php

    require 'config.php';

    if(isset($_post['pid'])){

    $pid = $_POST['pid'];

    $pname = $_POST['pname'];

    $pprice = $_POST['pprice'];

    $pcode = $_POST['pcode'];

    $pqty = $_POST['pqty'];

    $pcolour = $_POST['pcolour'];

    $pdis = $_POST['pdis'];

    $pimage = $_POST['pimage'];

    $QTY = 1;

    $stmt = $conn->prepare("SELECT Product_Code FROM cart WHERE Product_Code=?");

    $stmt->bind_param("s",$pcode);

    $stmt->execute();

    $res = $stmt->get_result();

    $r = $res->fetch_assoc();

    $code = $r['Product_Code'];

    if(!$code){

    $query = $conn->prepare(" INSERT INTO cart (Product_Code,Product_Colour,Product_Name,Product_Price,QTY,Total_Price,Product_Image) VALUES (?,?,?,?,?,?,?)");

    $query->bind_param("ssssiss",$pcode,$pcolour,$pname,$pprice,$pqty,$pprice, $pimage);

    $query->execute();

    echo '<div class="alert alert-success alert-dismissible">

    <button type="button" class="close" data-dismiss="alert">&times;</button>

    <strong>The selected Item has been added </strong>

    </div>';

    }

    else{

    echo '<div class="alert alert-danger alert-dismissible">

    <button type="button" class="close" data-dismiss="alert">&times;</button>

    <strong>The selected Item has been already added </strong>

    </div>';

    }

    }

    ?>

    from index.php
    <div class="container">

    <div id="message"></div>

    <div class="row mt-2 pb-3">

    <?php

    include'config.php';

    $stmt = $conn->prepare("SELECT * FROM product");

    $stmt->execute();

    $result = $stmt->get_result();

    while($row = $result->fetch_assoc()):

    ?>

    <div class="col-sm-6 col-md-4 col-lg-3 mb-2">

    <div>

    <font class="SmallB">Product code:</font>

    <font class="italic"><?= $row['Product_Code']?></font>

    </div>

    <div class="card-deck">

    <div class="card p-2 border-secondary md-2">

    <img src="<?= $row['Product_Image'] ?>" class="card-img-top" height="250px">

    <div class="card-body p-1">

    <h4 class="card-title text-center text-info"><?= $row['Product_Name']?></h4>

    <p class="para">

    <?= $row['Product_Description']?>

    </p>

    <h5 class="card-text text-center text-danger">

    PRICE <i class='fas fa-dollar-sign'

    style='font-size:15px'></i><?= number_format($row['Product_Price'],2)?>

    <BR>

    <font class="QTY">

    Quanity available is <?= $row['Product_QTY']?> </font>

    </h5>

    </div>

    <div class="card-footer p-1">

    <form action="" class="form-submit">

    <input type="hidden" class="pid" id="pid" value="<?= $row['ID']?>">

    <input type="hidden" class="pname" id="pname" value="<?= $row['Product_Name']?>">

    <input type="hidden" class="pprice" value="<?= $row['Product_Price']?>">

    <input type="hidden" class="pcode" value="<?= $row['Product_Code']?>">

    <input type="hidden" class="qty" value="<?= $row['Product_QTY']?>">

    <input type="hidden" class="pcolour" value="<?= $row['Product_Colour']?>">

    <input type="hidden" class="pdis" value="<?= $row['Product_Description']?>">

    <button class="btn btn-info btn-block addItemBtn"><i class="fas

    fa-cart-plus"></i>&nbsp; Add to Cart</button>

    </form>

    </div>

    </div>

    </div>

    </div>

    <?php endwhile; ?>

    </div>

    </div>

    <!– jQuery library –>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script&gt;

    <!– Popper JS –>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script&gt;

    <!– Latest compiled JavaScript –>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script&gt;

    <script type="text/javascript">

    $(document).ready(function(){

    $(".addItemBtn").click(function(e){

    e.preventDefault();

    var $form = $(this).closest(".form-submit");

    var pid =$form.find(".pid").val();

    var pname =$form.find(".pname").val();

    var pprice =$form.find(".pprice").val();

    var pcode =$form.find(".pcode").val();

    var pqty =$form.find(".pqty").val();

    var pcolour =$form.find(".pcolour").val();

    $.ajax({

    url: 'action.php',

    method: 'post',

    data: {pid:pid,pname:pname,pprice:pprice,pcode:pcode,pqty:pqty,pcolour:pcolour},

    success:function(response){

    $("#message").html(response);

    }

    });

    });

    });

    </script>

    </body>

    </html>

  6. Payal Singh
    November 21, 2020 at 22:18

    After clicking on add to cart button nothing happens please solve this problem

  7. Low Zhi Lok
    November 21, 2020 at 22:18

    can you teach me how to choose the size, price, add to cart, and quantity in PHP code?

  8. ROMAN JOHN LERIT
    November 21, 2020 at 22:18

    doesn't do anything when i click the add to cart

  9. Sue Patrick
    November 21, 2020 at 22:18

    very well explained.but i will need help, am trying to empty the cart automatically after checkout is done.it seems after checkout the cart is still having previous products in it.

  10. vishal jivani
    November 21, 2020 at 22:18

    Your code is not working properly for add to cart and not display when you select the add to cart not store in database and not show the output. please give some suggestions..

  11. Antonio J. Delgad
    November 21, 2020 at 22:18

    I have too some erros, can you give me the source code,it's grateful if you send it to me by my email: antoniojd121@gmail.com Thank you so much.

  12. אלדור פטורי
    November 21, 2020 at 22:18

    Notice: Trying to access array offset on value of type null in C:xampphtdocsaction.php on line 17
    What can I do

  13. Learning Redefined
    November 21, 2020 at 22:18

    Can we do it only using php ?

  14. Abigail Liguma
    November 21, 2020 at 22:18

    anyone figure out what the issue is with the not being able to add the item? i followed the code exactly but when i click the add to cart button nothing happens

  15. Deepu G Nair
    November 21, 2020 at 22:18

    thanks bro . it helps me a lot

  16. Spike x
    November 21, 2020 at 22:18

    hello i have some problems maybe you could give me soruce code ? sa79074@gmail.com

  17. E Shopper Sri Lanka
    November 21, 2020 at 22:18

    After Clicking Add to cart, nothing happens pls help me

  18. Talha Ahmed
    November 21, 2020 at 22:18

    sir nothing happen when i click on add to cart button please help me i check my full code to many times i dont understand why

  19. φ AQ ecнo ツ
    November 21, 2020 at 22:18

    The add to cart is not updating the products to the database. I watched all first 3 videos twice, and checked the syntax.
    Do you have the source code for this please?

  20. Hossain Masud
    November 21, 2020 at 22:18

    Hi
    I did check 3 times to all the code in index.php and action.php for add to cart product(in cart symbol) but i cant see in cart no product but its showing in database and all message are correct too.
    how can I solve the problem?i need to submit my assignment this sunday.it will be really helpful if you can figure out somthing.

    Thank you

  21. Plutiik
    November 21, 2020 at 22:18

    Hey I contacted you on email and facebook, can you please check it? Thank you so much!

  22. Anuar Tobaniyaz
    November 21, 2020 at 22:18

    Who solved the problem with “Add to card” button?

  23. Mihailo Sredovic
    November 21, 2020 at 22:18

    I have a question, why is my code not executing from $(document).ready(function() down to the end of </html>, when I run the file there are pictures and button but bellow that is just this code written on the page.
    Could you help please?

  24. bradox philemon
    November 21, 2020 at 22:18

    Sir this is great but what happens if users are more than one

  25. Ram Anuj
    November 21, 2020 at 22:18

    Notice: Trying to access array offset on value of type null in C:xampphtdocsmmtutsphpaction.php on line 17

    Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampphtdocsmmtutsphpaction.php:22 Stack trace: #0 {main} thrown in C:xampphtdocsmmtutsphpaction.php on line 22
    your code generate thiese error bro……

  26. Luis Alva
    November 21, 2020 at 22:18

    I keep getting a notice saying Trying to access array offset on value of type null in C:xampphtdocsproject1action.php on line 21 , whenever I added an item to cart. The item will still get added to cart and database but I still get the notice, did anyone else have this problem?

  27. +
    November 21, 2020 at 22:18

    How would you write the code without MYSQLND? I can't use get_result()

  28. 3DMotion Creative Web
    November 21, 2020 at 22:18

    Whats wrong in my code —- <b>Notice</b>: Undefined index: package_id in <b>C:xampphtdocscreativewebserviceadd_to_cart.php</b> on line <b>3</b><br />
    my cart data not send to ajax page

  29. jyotisman moitra
    November 21, 2020 at 22:18

    I want to ask one thing what for indeviduals cart when users are not logged in. as for example if we see on flipkart that they can handle indeviduals (not regiaterd user) cart separately.

  30. jyotisman moitra
    November 21, 2020 at 22:18

    sir what happen when a new user add the item to the cart

  31. Yeamin Rabbi
    November 21, 2020 at 22:18

    Notice: Trying to access array offset on value of type null in $code = $r['product_code'];

    what is the problem here???

  32. mariuusz01
    November 21, 2020 at 22:18

    Hey
    good work, but I have some error and I can't find it, if you can, send me the source code mariuusz01@gmail.com

  33. Aniket Adarsh
    November 21, 2020 at 22:18

    if you are not able to insert data into database , just check your jquery version and replace your slim version with regular version

  34. Ronald Lee
    November 21, 2020 at 22:18

    Ok I solved the problem I should select cart table not product table. Sorry!

  35. fariyah20 shahzad
    November 21, 2020 at 22:18

    please reply me

  36. fariyah20 shahzad
    November 21, 2020 at 22:18

    when I click on add to cart button data is not inserting in database please help :((((

  37. sazzad ahmed
    November 21, 2020 at 22:18

    sir , i press add to cart button, it didnt insert into my database and not show thwe successfully massage and danger massage , my code is alredy 4 time checking i'm not code mistake so please sir your source code give me …..sazzadahmed109@gmail.com

  38. sudhir kumar Yadav
    November 21, 2020 at 22:18

    i need your help , will you plase send me the source code of this

  39. sudhir kumar
    November 21, 2020 at 22:18

    I have some erros, can you give me the source code please! Email:-sudhirkumary7@gmail.com

  40. vaibhav sinha
    November 21, 2020 at 22:18

    Finally your code is working…. thanku sir,,, you'r great👍👍🙂

  41. vaibhav sinha
    November 21, 2020 at 22:18

    Don't make this type of video ,, which works only for you and not for users .

  42. vaibhav sinha
    November 21, 2020 at 22:18

    your code is not working .. help me

  43. krethick chakravarthy
    November 21, 2020 at 22:18

    Sir Can you pls send the code

  44. CHITRANJAN KUMAR
    November 21, 2020 at 22:18

    Where did the value of the cart_item come from
    in load_cart_item_number()????????????…………………………

  45. אושר רווח
    November 21, 2020 at 22:18

    After Clicking Add to cart, nothing happens. using Sublime text 3 + Xampp, Source Code of Part3 please!!

  46. Sundul Zundul
    November 21, 2020 at 22:18

    in my data base where image_product value is 0, Please help me can't find what problem?

  47. Fury Hounds
    November 21, 2020 at 22:18

    Hey, I would like to ask, why everytime i press add to cart button, it didnt insert into my database?

    The only difference i had is that i used foreign keys for the name and price

  48. King Hassan
    November 21, 2020 at 22:18

    I really don't know what I done diffferently but after clicking the Add to Cart button, nothing happens.

  49. Ch Mazhar Haroon
    November 21, 2020 at 22:18

    Sir please help me

  50. Ch Mazhar Haroon
    November 21, 2020 at 22:18

    Sir details is not showing in cart table

Leave A Comment

You must be logged in to post a comment.