[ad_1]
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
50 responses to “#3 Shopping Cart With Checkout System Using Bootstrap 4, PHP, MySQLi & Ajax | Adding Product to Cart”
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.
Finally my code is working, thank you sir!
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
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
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">×</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">×</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> 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>
<!– Popper JS –>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!– Latest compiled JavaScript –>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<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>
After clicking on add to cart button nothing happens please solve this problem
can you teach me how to choose the size, price, add to cart, and quantity in PHP code?
doesn't do anything when i click the add to cart
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.
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..
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.
Notice: Trying to access array offset on value of type null in C:xampphtdocsaction.php on line 17
What can I do
Can we do it only using php ?
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
thanks bro . it helps me a lot
hello i have some problems maybe you could give me soruce code ? sa79074@gmail.com
After Clicking Add to cart, nothing happens pls help me
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
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?
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
Hey I contacted you on email and facebook, can you please check it? Thank you so much!
Who solved the problem with “Add to card” button?
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?
Sir this is great but what happens if users are more than one
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……
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?
How would you write the code without MYSQLND? I can't use get_result()
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
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.
sir what happen when a new user add the item to the cart
Notice: Trying to access array offset on value of type null in $code = $r['product_code'];
what is the problem here???
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
if you are not able to insert data into database , just check your jquery version and replace your slim version with regular version
Ok I solved the problem I should select cart table not product table. Sorry!
please reply me
when I click on add to cart button data is not inserting in database please help :((((
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
i need your help , will you plase send me the source code of this
I have some erros, can you give me the source code please! Email:-sudhirkumary7@gmail.com
Finally your code is working…. thanku sir,,, you'r great👍👍🙂
Don't make this type of video ,, which works only for you and not for users .
your code is not working .. help me
Sir Can you pls send the code
Where did the value of the cart_item come from
in load_cart_item_number()????????????…………………………
After Clicking Add to cart, nothing happens. using Sublime text 3 + Xampp, Source Code of Part3 please!!
in my data base where image_product value is 0, Please help me can't find what problem?
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
I really don't know what I done diffferently but after clicking the Add to Cart button, nothing happens.
Sir please help me
Sir details is not showing in cart table