【发布时间】:2017-11-06 17:19:53
【问题描述】:
Woocommerce 允许使用下面的代码来更新运费。
$('body').trigger('update_checkout', { update_shipping_method: true });
我正在使用自定义运输插件,并且能够通过 ajax 更新成本并最终更新我的总数。 问题是,update_checkout 只能在 billing_address_1、billing_city、shipping_city 和其他一些字段发生更改时起作用。所以我必须做如下的事情:
$("#billing_address_1").trigger("keypress").val(function(i,val){return val + ' -';});
$('body').trigger('update_checkout', { update_shipping_method: true });
有没有更好的方法来实现这一点,而不是让 woocommerce 的表单变脏以更新运费?
提前致谢!!
【问题讨论】:
标签: wordpress woocommerce