Files
drmaterac.pl/modules/ets_promotion/views/js/order.js
2025-01-06 20:47:25 +01:00

88 lines
4.5 KiB
JavaScript

/**
* Copyright ETS Software Technology Co., Ltd
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 website only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future.
*
* @author ETS Software Technology Co., Ltd
* @copyright ETS Software Technology Co., Ltd
* @license Valid for 1 website (or project) for each purchase of license
*/
$(document).ready(function(){
$(document).on('change','input[name="payment-option"]',function(e){
setTimeout(function(){ets_pr_rule.changePayment();},500);
});
if($('input[name="payment-option"]:checked').length)
ets_pr_rule.changePayment();
});
var ets_pr_rule = {
changePayment : function(){
if($(".js-cart-payment-step-refresh").length)
$(".js-cart-payment-step-refresh").addClass('js-cart-payment-step-refresh2').removeClass('js-cart-payment-step-refresh');
var $module_name = $('input[name="payment-option"]:checked').data('module-name');
if($('#pay-with-'+$('input[name="payment-option"]:checked').attr('id')+'-form input[name="id_payment_method"]').length)
var id_payment_method = $('#pay-with-'+$('input[name="payment-option"]:checked').attr('id')+'-form input[name="id_payment_method"]').val();
else
var id_payment_method =0;
$.ajax({
url: ets_pr_link_ajax_change_payment,
data: 'submitChangePayment=1&payment='+$module_name+'&id_payment_method='+id_payment_method,
type: 'post',
dataType: 'json',
success: function(json){
if($('#form_ets_onepagecheckout').length)
{
if($(".js-cart").data("refresh-url"))
{
$.ajax({
url: $(".js-cart").data("refresh-url"),
data: 'id_country='+$('#shipping_address_id_country').val()+($('#shipping_address_id_state').length ? '&id_state='+$('#shipping_address_id_state').val() :'')+($('#shipping_address_postal_code').length ? '&postal_code='+$('#shipping_address_postal_code').val():'')+($('.block-shop-license-info').length ? '&'+$('.block-shop-license-info input').serialize():''),
type: 'post',
dataType: 'json',
success: function(json){
$(".cart-detailed-totals").replaceWith(json.cart_detailed_totals);
$(".cart-summary-items-subtotal").replaceWith(json.cart_summary_items_subtotal);
$(".cart-summary-subtotals-container").replaceWith(json.cart_summary_subtotals_container);
$(".cart-summary-totals").replaceWith(json.cart_summary_totals);
$(".cart-detailed-actions").replaceWith(json.cart_detailed_actions);
$(".cart-voucher").replaceWith(json.cart_voucher);
$(".cart-overview").replaceWith(json.cart_detailed);
$(".js-cart-line-product-quantity").each(function(e, t) {
var n = $(t);
n.attr("value", n.val());
});
if(json.gift_label)
{
$('.gift_label label').html(json.gift_label);
}
prestashop.emit("updatedCart", {
eventType: "updateCart",
resp: json
});
}
});
}
}
else
prestashop.emit("updateCart", {
reason: {
idProduct: 0,
idProductAttribute: 0,
idCustomization: 0,
linkAction: "",
cart: json.cart
},
resp: json
});
}
});
}
}