IWD一页结帐扩展程序Magento:查看刷新 [英] IWD one page checkout extension Magento: review refresh

查看:83
本文介绍了IWD一页结帐扩展程序Magento:查看刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to use the onepagecheckout (one step checkout) extension from IWD, and use it with the Cash On Delivery extension from Phoenix.

我修改了代码,以便正确显示货到付款费用,但是需要3次加载时间才能在审核部分中正确显示总费用.有没有一种方法可以美化它,使其仅在后台显示一次正在加载",而在后台显示三次(否则该费用将无法正确显示)?

I modified the code so it shows the Cash On Delivery Fee correctly, but it takes 3 loading times to correctly show the total costs in the review part. Is there a way to beautify this so it only shows "loading" once, and three times in the background (otherwise the fee won't show correctly)?

这就是我所做的:

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

I've added this to the template in /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> 

所以它加载的审查,并支付额外的部分时,其他的发布方法已被选中(我只在交付使用现金与一个送货方式).

So it loads the review, and payment section extra when another delivery method has been selected (I only use cash on delivery with one shipping method).

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

In onepagecheckout.js I've added two pieces of code I've found on magentoproblems and on the magento-connect page of IWD

以上

 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});
}
}
} 

当运输方式更改时,付款部分会明显刷新两次,删除货到付款"选项(这是正确的),然后刷新三遍评论部分,因此费用可以增加方式,也可以从评论中删除/总计部分.

When the shipping method changes, the payment-section refreshes visibly twice, removes the Cash On delivery option (this is correct), and refreshes the review section three times, so the fee is either way added, or removed from the review/totals section.

预先感谢

推荐答案

OPC默认会在文档加载时更新审核:

OPC updates review on document load by default:

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

每次更改运输方式时都会更新评论"部分,因此您添加了2个额外的checkout.update({'...'})

and updates 'review' section each time shipping method was changed, so you added 2 extra checkout.update({'...'})

这篇关于IWD一页结帐扩展程序Magento:查看刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆