OK, changed several things with the above code to accomodate the cart section already being active, refreshing the cart quantity in the displayed area, and I was trying to make it possible to add more than 1 of the item to the shopping cart. FAIL!!
What would the variable I need to pass in to make it add more than 1 product? Here is what I have tried, and it doesn't work.
PHP Code:
<script type='text/javascript'>
var shoppingCart = false;
$("form#addProduct").submit(function(){
var product_id = $('input[name="products_id"]').val();
var cart_quantity = $('input[name="cart_quantity"]').val();
var securityToken = $('input[name="securityToken"]').val();
var url = "http://design.uniqueoutdoorproducts.com/index.php?action=buy_now&cart_quantity="+cart_quantity+"&products_id="+product_id; //$("#addProduct").attr('action');
/*
$("#ajaxCart").animate({
top: "0",
opacity: 1
}, 1000)
*/
//alert(securityToken+product_id);
var data= new Array();
data['product_id'] = product_id;
data['cart_quantity'] = cart_quantity;
data['securityToken'] = securityToken;
$.ajax({
type: 'POST',
url: url,
data: data,
success: function( data ) {
var shoppingCartUpdate = $(data).find('div#ajaxCartContainer');
$('div#ajaxCartContainer').html(shoppingCartUpdate);
//this is a result
if(!shoppingCart){
$("#ajaxCart").animate({
top: "+=250",
opacity: "1"
}, 1000, function(){
shoppingCart = true;
//$("#ajaxCart").html("Successfully added to Cart");
})
}
}
});
return false;
});
$("#showHideCartButton").click(function(){
if(shoppingCart){
$("#ajaxCart").animate({
top: "-250"
}, 1000)
shoppingCart = false;
} else {
$("#ajaxCart").animate({
top: "0"
}, 1000)
shoppingCart = true;
}
return false;
});
</script>
I have also tried changing the action to add_product, but that breaks even adding a single item to the cart. Really running into a wall here, any help would be appreciated.
Thanks!
Bookmarks