<script type="text/javascript">
$("#notify_btn").click(function() {
$("#msgoosn").html("");
$("#loadgif").show();
var e = $("#notifyname").length ? $("#notifyname").val() : "",
o = $("#notifyphone").length ? $("#notifyphone").val() : "";
stock_comment = $("#notifycomment").length ? $("#notifycomment").val() : "";
stock_qty = $("input[name='quantity']").length ? $("input[name='quantity']").val() : "1";
if ($("#option_values").length) var t = $("#option_values").val(),
n = $("#selected_option").val(),
a = $("#all_selected_option").val();
else var t = 0,
n = 0,
a = 0;
$.ajax({
type: "post",
url: "index.php?route=extension/module/product_oosn",
data: {
email: $("#notifyemail").val(),
gcaptcha: $("[name='g-recaptcha-response']").val(),
name: e,
phone: o,
stock_comment: stock_comment,
stock_qty: stock_qty,
product_id: $("#pid").val(),
selected_option_value: t,
selected_option: n,
all_selected_option: a
},
dataType: "json",
success: function(json) {
$("#loadgif").hide();
if (json['success']) {
$('#msgoosn').html('<span class="notify_form_success">'+json['success']+'</span>');
}
if (json['notify_error']) {
$('#msgoosn').html('<span class="notify_form_error">'+json['notify_error']+'</span>');
}
if (json['notify_warning']) {
$('#msgoosn').html('<span class="notify_form_warning">'+json['notify_warning']+'</span>');
}
},
error: function(e, o, t) { alert(t + "\r\n" + e.statusText + "\r\n" + e.responseText); $("#loadgif").hide(); }
})
});
</script>
<script type="text/javascript">
var cart = {
'add': function(product_id, quantity) {
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['hberror']){
if (json['hberror']['oosn']) {
notifypop(json['hberror']['oosn']);
return false;
}
}
if (json['redirect']) {
location = json['redirect'];
}
if (json['success']) {
$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
$('html, body').animate({ scrollTop: 0 }, 'slow');
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
}
});
},
'update': function(key, quantity) {
$.ajax({
url: 'index.php?route=checkout/cart/edit',
type: 'post',
data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
'remove': function(key) {
$.ajax({
url: 'index.php?route=checkout/cart/remove',
type: 'post',
data: 'key=' + key,
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}
</script>
$("#notify_btn").click(function() {
$("#msgoosn").html("");
$("#loadgif").show();
var e = $("#notifyname").length ? $("#notifyname").val() : "",
o = $("#notifyphone").length ? $("#notifyphone").val() : "";
stock_comment = $("#notifycomment").length ? $("#notifycomment").val() : "";
stock_qty = $("input[name='quantity']").length ? $("input[name='quantity']").val() : "1";
if ($("#option_values").length) var t = $("#option_values").val(),
n = $("#selected_option").val(),
a = $("#all_selected_option").val();
else var t = 0,
n = 0,
a = 0;
$.ajax({
type: "post",
url: "index.php?route=extension/module/product_oosn",
data: {
email: $("#notifyemail").val(),
gcaptcha: $("[name='g-recaptcha-response']").val(),
name: e,
phone: o,
stock_comment: stock_comment,
stock_qty: stock_qty,
product_id: $("#pid").val(),
selected_option_value: t,
selected_option: n,
all_selected_option: a
},
dataType: "json",
success: function(json) {
$("#loadgif").hide();
if (json['success']) {
$('#msgoosn').html('<span class="notify_form_success">'+json['success']+'</span>');
}
if (json['notify_error']) {
$('#msgoosn').html('<span class="notify_form_error">'+json['notify_error']+'</span>');
}
if (json['notify_warning']) {
$('#msgoosn').html('<span class="notify_form_warning">'+json['notify_warning']+'</span>');
}
},
error: function(e, o, t) { alert(t + "\r\n" + e.statusText + "\r\n" + e.responseText); $("#loadgif").hide(); }
})
});
</script>
<script type="text/javascript">
var cart = {
'add': function(product_id, quantity) {
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['hberror']){
if (json['hberror']['oosn']) {
notifypop(json['hberror']['oosn']);
return false;
}
}
if (json['redirect']) {
location = json['redirect'];
}
if (json['success']) {
$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
$('html, body').animate({ scrollTop: 0 }, 'slow');
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
}
});
},
'update': function(key, quantity) {
$.ajax({
url: 'index.php?route=checkout/cart/edit',
type: 'post',
data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
'remove': function(key) {
$.ajax({
url: 'index.php?route=checkout/cart/remove',
type: 'post',
data: 'key=' + key,
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}
</script>