dsjbest2014 2018-11-05 10:14
浏览 85
已采纳

在结帐时刷新缓存的送货方式更新Woocommerce中的ajax事件

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";
        unset(WC()->session->$shipping_session);
    }
}, 10, 2);

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

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 香农解码的代码问题,无法输出解码结果
      • ¥15 Python操作注册表
      • ¥45 入门级别的一段VUE前端拍照像后端发送请求的代码,帮排错
      • ¥15 anaconda打开spyder后一直闪退,不知道怎么办
      • ¥15 解决迷宫问题中无法运行的问题
      • ¥15 关于aspnetcore中使用mqttnet库的entire
      • ¥15 关于#python#的问题,请各位专家解答!
      • ¥100 关于远控软件的两个问题
      • ¥15 基于STM32的AD8232心电采集装置设计
      • ¥15 我在wordpress里安装Ultimate menber 插件之后进行测试,点击注册之后发现网页打不了