我想使用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});
}
}
} 当发货方式改变时,付款部分会明显地刷新两次,删除“货到付款”选项(这是正确的),并刷新三次审查部分,因此费用将以任何方式添加,或从审查/合计部分中删除。
提前感谢
发布于 2013-12-06 03:45:57
默认情况下,OPC会在加载文档时进行更新审核:
window.onload = function () {
checkout.update({
'payment-method': 1,
'shipping-method': 1,
'review': 1
})并在每次更改发货方式时更新“评论”部分,因此您添加了2个额外的checkout.update({'...'})
https://stackoverflow.com/questions/20349870
复制相似问题