IWD单页结帐扩展Magento:评论刷新

时间:2013-12-03 11:26:50

标签: magento

我想使用IWD的onepagecheckout(一步结帐)扩展程序,并将其与Phoenix的Cash On Delivery扩展程序一起使用。

我修改了代码,因此它正确显示了现金交付费用,但是需要3次加载时间才能正确显示评论部分的总费用。有没有办法美化这个,所以它只显示“加载”一次,并在后台显示三次(否则费用将无法正确显示)?

这就是我所做的:

我已将此添加到/template/onepagecheckout/onepagecheckout.phtml中的模板中:

 <script type="text/javascript" >
$j(function($) {
$j('input[name*="payment[method]"]').live('click', function() {
checkout.update2({
'review': 1,
'payment-method': 1
});
});
$j('input[name*="shipping_method"]').live('click', function() {
checkout.update({
'review': 1
,'payment-method': 1
});
setTimeout(function(){
checkout.update({
'review': 1,
});
}, 500);
});
});
</script> 

因此,当选择了另一种交付方式时,它会加载评论和额外付款部分(我只使用货到付款方式)。

在onepagecheckout.js中我添加了两段我在magentoproblems和IWD的magento-connect页面上找到的代码

上方

 setResponse: function (response) { 

我添加了

     update2: function (params) {
if (this.loadWaiting != false) {
return
}
if (this.s_code == '') return this.opcdis();
var parameters = $(this.form).serialize(true);
for (var i in params) {
if (!params[i]) {
continue
}
var obj = $('checkout-' + i + '-load');
if (obj != null) {
var size = obj.getDimensions();
obj.setStyle({
'width': size.width + 'px',
'height': size.height + 'px'
}).update('').addClassName('loading');
parameters[i] = params[i]
}
}
checkout.setLoadWaiting(true);
var request = new Ajax.Request(this.updateUrl, {
method: 'post',
onSuccess: this.setResponse2.bind(this),
onFailure: this.ajaxFailure.bind(this),
parameters: parameters
})
},
setResponse2: function (response) {
response = response.responseText.evalJSON();
if (response.redirect) {
location.href = check_secure_url(response.redirect);
return true
}
checkout.setLoadWaiting(false);
if (response.order_created) {
$('onepagecheckout_orderform').action = this.successUrl;
$('opc_submit_form').click();
return true
} else if (response.error_messages) {
var msg = response.error_messages;
if (typeof (msg) == 'object') {
msg = msg.join("\n")
}
alert(msg)
}
$('review-please-wait').hide();
if (response.update_section) {
for (var i in response.update_section) {
ch_obj = $('checkout-' + i + '-load');
if (ch_obj != null) {
ch_obj.setStyle({
'width': 'auto',
'height': 'auto'
}).update(response.update_section[i]).setOpacity(1).removeClassName('loading');
if (i === 'shipping-method') {
shippingMethod.addObservers()
}
}
}
}
if (response.duplicateBillingInfo) {
shipping.syncWithBilling()
}
if (!response.reload_totals) {
checkout.update({
'review': 1
})
}
return false
}, 

我已经取代了

 this.currentMethod = method; // This code was here before

this.currentMethod = method; // This code was here before
var shippingMethods = document.getElementsByName('shipping_method');
if (shippingMethods.length != 0) {
for (var i = 0; i < shippingMethods.length; i++) {
if (shippingMethods[i].checked) {
checkout.update({'review': 1});
}
}
} 

当送货方式更改时,付款部分会刷新两次,取消现金交付选项(这是正确的),并刷新审核部分三次,因此要么添加费用,要么从审核中删除/总计部分。

提前致谢

1 个答案:

答案 0 :(得分:1)

默认情况下,OPC会更新文档加载审核:

window.onload = function () {
    checkout.update({
        'payment-method': 1,
        'shipping-method': 1,
        'review': 1
    })

并在每次更改送货方式时更新“评论”部分,因此您添加了2个额外的checkout.update({'...'})

相关问题