【发布时间】: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