Unc*_*ror 7 ajax wordpress hook-woocommerce
jQuery函数需要在发布选项更新后,在结帐页面上,通过ajax调用初始化,并且updated_shipping_method
已触发Woocommerce自定义事件.
我的jQuery代码片段设置为侦听此事件 - 但这不符合预期.
jQuery( document.body ).on( 'updated_shipping_method', function(){
// Code stuffs
// has the function initialized after the event trigger?
console.log('on updated_shipping_method: function fired');
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过updated_wc_div
自定义事件但无济于事.
我在购物车页面上使用类似的方法,几乎逐字逐句地听取自定义事件触发器updated_cart_totals
并且它完美地工作.不确定为什么结帐页面不是这种情况.
Unc*_*ror 10
正确的自定义事件: updated_checkout
有问题的代码片段正在侦听错误的Woocommerce自定义事件.
在这种情况下要收听的正确自定义事件是updated_checkout
.
选择新的送货方式时,Woocommerce会触发ajax调用以更新购物车总数以反映所选送货方式的价格,然后触发updated_checkout
.
因此,如果updated_checkout
被收听,而不是updated_shipping_method
按预期触发脚本.
归档时间: |
|
查看次数: |
4508 次 |
最近记录: |