Wordpress woocommerce结帐多次更新发货价值

Wordpress woocommerce结帐多次更新发货价值,wordpress,woocommerce,Wordpress,Woocommerce,Woocommerce允许使用下面的代码更新运输成本 $('body').trigger('update_checkout', { update_shipping_method: true }); 我使用一个定制的运输插件,我能够通过ajax更新成本,并最终更新我的总成本。 问题是,只有当账单地址、账单城市、发货城市和其他几个字段发生更改时,更新账单签出才能工作。所以我必须做如下的事情: $("#billing_address_1").trigger("keypress").val(funct

Woocommerce允许使用下面的代码更新运输成本

$('body').trigger('update_checkout', { update_shipping_method: true });
我使用一个定制的运输插件,我能够通过ajax更新成本,并最终更新我的总成本。 问题是,只有当账单地址、账单城市、发货城市和其他几个字段发生更改时,更新账单签出才能工作。所以我必须做如下的事情:

$("#billing_address_1").trigger("keypress").val(function(i,val){return val + ' -';});
$('body').trigger('update_checkout', { update_shipping_method: true }); 
有没有更好的方法来实现这一点,除了让表单变脏,以便woocommerce更新运输成本


提前谢谢

这是woocommerce的设计。此脚本假定更改地址或国家时需要更新

  jQuery('body').trigger('update_checkout');

  /* what this does is update the order review table but what it doesn't do is update shipping costs;
     the calculate_shipping function of your shipping class will not be called again;
     so if you were like me and you made a shipping method plugin and you had to change costs based on payment method then
     this is the only way to ensure it does just that
  */
如果您想让事情顺利进行,请将此添加到插件文件或functions.php中:

引自:

要了解原因,请阅读以下文章:
这是woocommerce的设计。此脚本假定更改地址或国家时需要更新

  jQuery('body').trigger('update_checkout');

  /* what this does is update the order review table but what it doesn't do is update shipping costs;
     the calculate_shipping function of your shipping class will not be called again;
     so if you were like me and you made a shipping method plugin and you had to change costs based on payment method then
     this is the only way to ensure it does just that
  */
如果您想让事情顺利进行,请将此添加到插件文件或functions.php中:

引自:

要了解原因,请阅读以下文章:

不幸的是,这不起作用。我还发现,jQuery('body').trigger('update_checkout');始终工作,但不在客户端更新。我使用ajax获取运输成本,得到了更新后的数据,但在结帐页面上无法更新,在提交订单时,使用了客户端结帐页面上的值,而不是WC会话上的值。我使用WC会话变量来更新运费率数组。我用storefront安装了普通wordpress,并触发dom事件,重新加载运费。通常在wordpress中,其他插件会破坏某些行为。您确定所有字段都已正确填充吗?你能给我一个关于这个问题的网站链接吗?现在不能公开url:我的配送插件使用谷歌地图显示路线,你必须点击服务选项,如“当天配送”、“1周配送”e.t.c,它返回新的配送值。此传送值由ajax提交到WC->session变量,然后触发checkout\u更新,剩下的由WC完成。我可以通过电子邮件发送u-link。当然,如果您还有问题,请通过电子邮件发送给我daniel[at]pikselownia.com。不幸的是,这不起作用。我还发现,jQuery('body').trigger('update_checkout');始终工作,但不在客户端更新。我使用ajax获取运输成本,得到了更新后的数据,但在结帐页面上无法更新,在提交订单时,使用了客户端结帐页面上的值,而不是WC会话上的值。我使用WC会话变量来更新运费率数组。我用storefront安装了普通wordpress,并触发dom事件,重新加载运费。通常在wordpress中,其他插件会破坏某些行为。您确定所有字段都已正确填充吗?你能给我一个关于这个问题的网站链接吗?现在不能公开url:我的配送插件使用谷歌地图显示路线,你必须点击服务选项,如“当天配送”、“1周配送”e.t.c,它返回新的配送值。此传送值由ajax提交到WC->session变量,然后触发checkout\u更新,剩下的由WC完成。我可以通过电子邮件发送u-link。当然,如果您还有问题,请通过电子邮件发送给我daniel[在]pikselownia.com