2018-11-05 10:14
浏览 83


i just implemented a custom shipping solution.

It depends on the total price of items in the cart. For example:

if total is < 20   -> display free shipping
if total is >= 20  -> paid delivery

But i have a problem with woocommerce cache...I think that the fact is that woocommerce caches shipping rates, not taking in account order qty change. So is the problem is with the calculate_shipping_for_package() method?

If I enable shipping debug mode everything works just right, without it got no updates.

I tried to disable cache, without success with.

add_action('woocommerce_checkout_update_order_review', function() {
    $packages = WC()->cart->get_shipping_packages();
    foreach ($packages as $key => $value) {
        $shipping_session = "shipping_for_package_$key";
}, 10, 2);

So. Do you ever had this kind of problem? How did you solve? Thanks a lot for any help!

图片转代码服务由CSDN问答提供 功能建议


这取决于购物车中商品的总价格。 例如:

 如果total是&lt;  20  - &gt; 显示免费送货
if total is&gt; = 20  - &gt; 付费交付

但是我对woocommerce缓存存在问题...我认为事实是,woocommerce缓存运费,而不考虑订单数量的变化。 <问题是 calculate_shipping_for_package()方法?



 $ packages = WC(  ) - &gt; cart-&gt; get_shipping_packages(); 
 foreach($ packages as $ key =&gt; $ value){
 $ shipping_session =“shipping_for_package_ $ key”; 
 unset(WC() - &gt; session  - &gt; $ shipping_session); 

所以。 你有过这种问题吗? 你是怎么解决的? 非常感谢您的帮助!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题