I am using the CodeIgniter shopping cart.
I have an add to cart button. so when the user clicks on it then it will send the product information to the controller. Now I am just sending the information to the jQuery. It's just for testing purpose after some time I will send it to the controller using Ajax.
SO when I click on the button
<button type="button" name="addtocart" class="btn btn-success add_cart" data-productname="" data-price="" data-productid="" />Add to cart</button>
then it sends the below information to the jQuery. I just want to know is there any more option. I mean I have to add some user_id, username
etc.
data-productname
data-price
data-productid
$('.add_cart').click(function(){
var product_name = $(this).data("productname");
var product_id = $(this).data("productid");
var product_price = $(this).data("price");
var quantity =1;
//data:{product_id:product_id, product_name:product_name, product_price:product_price,quantity:quantity},
)};
In the controller, I am displaying the details
$data = array(
"id" => $_POST["product_id"],
"name" => $_POST["product_name"],
"qty" => $_POST["quantity"],
"price" => $_POST["product_price"]
);