I have a almost finish webshop with a product catalog page (with multiple products) and a product info/overview page (only one product).
The product catalog page holds a "read more" that will go to the product info page where there is a buy button and a qty input.
This is all working fine.
But now the customer wants buy buttons one the product catalog page (incl. qty input). This is giving me some problems - i have figured out how to add the product to cart but can't get the value of the qty input field right. it adds 6 of the product to the cart even if "productkolli" is fx. 1.
Can anyone tell me what im doing wrong?
i'm using jquery to add the products to cart.
Here my form template:
<form class="addtocartform" name="addtocartform" action="Kurv/kurv.php">
<input type="text" class="qty" name="' . $productID . '" id="' . $productID . '" value="' . $productKolli . '"/>
</form></div>
<div class="addtocartbtn" id="' . $productID . '"><a href="#">add</a></div>
Here my jquery:
$('.addtocartbtn').click(function(){
// Get product ID
var product_id = this.id;
// Get qty
var qty = document.getElementById(<?php echo $productID ?>).value;
//var qty = $(this).closest("input");
//var qty = $('input[class=qty]').val();
// right here, you could add the product to your shopping cart application
performing an asynchronous HTTP request...
$.get( "Kurv/kurv.php", { action: "add", id: product_id, qty: qty } );