I am using jQuery and Ajax to add items to a shopping cart and in all areas of the site apart from one it works fine and I cannot for the life of me work out why this one area isn't working.
The form code (which is the same as in all other Add To Cart forms) is:
<form method="" class="add_to_cart">
<input type="hidden" name="item_id" value="prods_<?php echo $prodid;?>" />
<input type="hidden" name="unit_price" value="<?php echo $price;?>" />
<input type="hidden" name="item_name" value="<?php echo $objproducts->prod_name.' - '.$objproducts->prod_code;?>" />
<input type="hidden" name="image" value="/images/products_tb/<?php echo $objproducts->prod_img; ?>" />
<input type="hidden" name="item_qty" value="1"/>
<input type="hidden" name="item_url" value="/diesel_engine_products/<?php echo $catid; ?>/<?php echo $objproducts->prodid; ?>/"/>
<input type="submit" class="rounded-buttons" name="add_to_bag" value="Add to Bag" />
</form>
The jQery/Ajax is:
$('.add_to_cart').submit(function (e) {
e.preventDefault();
var currentUrl = window.location.href.substr(window.location.href.lastIndexOf("/") + 1);;
$.ajax({
url: '/inc/shopping_bag_functions.php',
data: $(this).serialize() + '&action=add',
type: 'POST',
success: function(html) {
$('#shopping-bag p').html(html);
$('.add-item')
.fadeIn('fast')
.dialog({
height: 100,
modal:true
});
if(currentUrl == '/shopping-bag.php') {
$('.add-item').fadeOut(1000, function() {
$(".add-item").dialog('close');
});
$("#inner-content").load(location.href + " #inner-content>*", "");
}
}
});
});
The page where this is not working on the site is when viewing individual products, for example This Page.
Can anyone see the problem as I can't and am fairly sure it is something simply