I searched everywhere on stackoverflow and google it but still I did not found any solution, so I am posting it here. Please help me to resolve it.
1.Normal e commerce site with add products to cart without refreshing the page and has to start countdown timer for each products seperately(It's a unique product and has to buy it within the time, jiust like auction).
2.When the user clicks on checkout has to freeze the timer and if he comes back to shop again has to start the timer where it has freeze.
So here is my code for onclick add to cart function
<input type="button" onClick = "cartAction('add','productId','Timer')" />
In script
function cartAction(action, id, time) {
var queryString = "";
if (action != "") {
switch (action) {
case "add":
queryString = 'action=' + action + '&id=' + id + '&quantity=1' + '&time=' + time;
break;
case "remove":
queryString = 'action=' + action + '&id=' + id;
break;
case "empty":
queryString = 'action=' + action;
break;
}
}
jQuery.ajax({
url: "ajax_action.php",
data: queryString,
type: "POST",
success: function (data) {
$("#cart-item").html(data);
$("#amount-top").html($("#total").val());
$("#item-total").html($("#carttotal").val());
if (action != "") {
switch (action) {
case "add":
$("#add_" + id).hide();
$("#added_" + id).show();
break;
case "remove":
$("#add_" + id).show();
$("#added_" + id).hide();
break;
case "empty":
$("#amount-top").html(0);
$("#item-total").html(0);
break;
}
}
},
error: function () {
}
});
}
And finally in ajax_action call is
How to freeze timer when checkout clicked and how to release the timer when user wants to add some more products to cart..
Thanks in advance.