// Bug fix : Mobile, js errors fixed
This commit is contained in:
@@ -88,6 +88,20 @@ function initEvent()
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierList(json)
|
||||
{
|
||||
var html = json.carrier_block;
|
||||
|
||||
// @todo check with theme 1.4
|
||||
//if ($('#HOOK_EXTRACARRIER').length == 0 && json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined)
|
||||
// html += json.HOOK_EXTRACARRIER;
|
||||
|
||||
$('#carrier_area').replaceWith(html);
|
||||
bindInputs();
|
||||
/* update hooks for carrier module */
|
||||
$('#HOOK_BEFORECARRIER').html(json.HOOK_BEFORECARRIER);
|
||||
}
|
||||
|
||||
function giftShowDiv()
|
||||
{
|
||||
if ($('#gift').is(':checked'))
|
||||
@@ -134,3 +148,161 @@ function updateCarrierSection(elm)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindInputs()
|
||||
{
|
||||
// Order message update
|
||||
$('#message').blur(function() {
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Recyclable checkbox
|
||||
$('#recyclable').click(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Gift checkbox update
|
||||
$('#gift').click(function() {
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
|
||||
// Gift message update
|
||||
$('#gift_message').change(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Term Of Service (TOS)
|
||||
$('#cgv').click(function() {
|
||||
updatePaymentMethodsDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierSelectionAndGift()
|
||||
{
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
if ($(this).prop('checked'))
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&';
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
if ($('input#gift:checked').length)
|
||||
{
|
||||
gift = 1;
|
||||
giftMessage = encodeURIComponent($('#gift_message').val());
|
||||
}
|
||||
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
refreshDeliveryOptions();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePaymentMethods(json)
|
||||
{
|
||||
$('#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
|
||||
$('#opc_payment_methods-content #HOOK_PAYMENT').html(json.HOOK_PAYMENT);
|
||||
}
|
||||
|
||||
function updatePaymentMethodsDisplay()
|
||||
{
|
||||
var checked = '';
|
||||
if ($('#cgv:checked').length !== 0)
|
||||
checked = 1;
|
||||
else
|
||||
checked = 0;
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow', function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
updatePaymentMethods(json);
|
||||
}
|
||||
});
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user