【问题标题】:IWD one page checkout extension Magento: review refreshIWD 一页结帐扩展 Magento:审查刷新
【发布时间】:2013-12-03 11:26:49
【问题描述】:

我想使用 IWD 的 onepagecheckout(一步结账)扩展程序,并将其与 Phoenix 的货到付款扩展程序一起使用。

我修改了代码,使其正确显示货到付款费用,但需要 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});
}
}
} 

当运输方式发生变化时,付款部分明显刷新两次,删除货到付款选项(这是正确的),并刷新审查部分 3 次,因此无论是添加费用,还是从评论中删除费用/总计部分。

提前致谢

【问题讨论】:

    标签: magento


    【解决方案1】:

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

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

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

    【讨论】:

    • 我需要这些刷新时刻来正确更新评论部分,但我怎样才能在后台进行多次刷新,而查看者/客户只需一次“加载”时间?我认为它与 real_update 函数和这一行有关:` }).update('').addClassName('loading');` 但我不知道如何正确添加刷新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    • 2014-10-25
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    • 2014-07-11
    • 1970-01-01
    相关资源
    最近更新 更多