【问题标题】:Without coupon = Shipping free, with coupon = with shipping - WooCommerce没有优惠券 = 免运费,有优惠券 = 有运费 - WooCommerce
【发布时间】:2019-07-29 21:17:04
【问题描述】:

我的 WooCommerce 商店需要帮助。 我们的客户在 39 欧元后获得免费送货服务。 如果我们的客户在使用优惠券后得到的价格低于 39 欧元,则不再免费送货。

例如:

客户在购物车上,购物车的全部金额为 42 欧元 = 免运费。

使用 -15% 的优惠券 = 购物车金额为 38,55 = 运费

在我使用的插件中,我可以设置“允许免费送货”,但是客户在获得优惠券的最低金额后就可以免费送货,所以这对我们没有用。

我使用插件 = WooCommerce 扩展优惠券功能免费 https://de.wordpress.org/plugins/woocommerce-auto-added-coupons/

希望你们明白我的意思

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    您可以通过使用简单的代码 sn-p 来实现这一点。

    您需要配置一个免费送货,没有任何最低订单金额和统一费率才能显示正常送货。

    现在将sn-p下面的内容复制并粘贴到functions.php中。如果小计小于 39,它将隐藏免费送货,否则隐藏统一费率

    add_filter( 'woocommerce_package_rates',  'modify_shipping_rate', 15, 2 );
    function modify_shipping_rate( $available_shipping_methods, $package ){
    
        global $woocmmerce;
        $total_coast = WC()->cart->get_subtotal();
    
        if( $total_coast < 39 ){
            unset($available_shipping_methods['free_shipping:4']); // Config the Free Shipping method id properly
        }else{
            unset($available_shipping_methods['flat_rate:1']); //// Config the Flatrate shipping method id properly
        }
    
        return $available_shipping_methods;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-09-08
      • 2022-01-22
      • 2014-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多