如何解决onShippingChange 不适用于 data.shipping_address.country_code
我正在尝试将其设置为拒绝除英国以外的所有送货地址。我的代码如下;
onShippingChange: function(data,actions){
if(data.shipping_address.country_code!=="GB"){
return actions.reject();
}
return actions.resolve();
},
但它不起作用。我没有收到任何错误。
我也尝试将其更改为以下内容,但也不起作用;
return actions.reject(new Error("We do not support your country."));
我可以让它稍微工作的唯一方法是,如果我使用警报并抛出一个新错误而不是使用拒绝(),例如;
onShippingChange: function(data,actions){
if(data.shipping_address.country_code!=="GB"){
alert("We do not support your country.");
throw new Error();
}
},
但这样做不会关闭 PayPal 弹出窗口/模式。
解决方法
尝试在 else 语句中包含 return actions.resolve();
,无论 return actions.reject();
是什么,我都可能会被调用
onShippingChange: function(data,actions){
if(data.shipping_address.country_code!=="GB"){
return actions.reject();
} else {
return actions.resolve();
}
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。