Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我如何为Woocommerce中的特定支付方式设置免费配送?_Php_Wordpress_Woocommerce_Shipping_Payment Method - Fatal编程技术网

Php 我如何为Woocommerce中的特定支付方式设置免费配送?

Php 我如何为Woocommerce中的特定支付方式设置免费配送?,php,wordpress,woocommerce,shipping,payment-method,Php,Wordpress,Woocommerce,Shipping,Payment Method,我在一个网站上有两种付款方式,客户要求我为超过X金额的订单设置免费送货(这不是问题),如果客户使用银行转账作为付款方式 我尝试了很多插件,但它们只能从总金额中添加和删除费率,因此,如果我设置删除银行转账的运费,但订单高于X金额(这将提供免费运费),那么插件最终只会降低运费的总价格 知道怎么办吗?在Stackoverflow或Google上找不到任何内容 这将部分回答您的问题,因为它相当复杂,我们不提供StackOverFlow中的免费开发,因为您不提供任何代码,甚至不提供您尝试过的插件的参考或详

我在一个网站上有两种付款方式,客户要求我为超过X金额的订单设置免费送货(这不是问题),如果客户使用银行转账作为付款方式

我尝试了很多插件,但它们只能从总金额中添加和删除费率,因此,如果我设置删除银行转账的运费,但订单高于X金额(这将提供免费运费),那么插件最终只会降低运费的总价格


知道怎么办吗?在Stackoverflow或Google上找不到任何内容

这将部分回答您的问题,因为它相当复杂,我们不提供StackOverFlow中的免费开发,因为您不提供任何代码,甚至不提供您尝试过的插件的参考或详细信息

以下是一段基于WooCommerce官方代码片段的代码,当您达到目标购物车金额时,它将隐藏其他配送方法:

// Only for WooCommerce version 2.6+

// Hidding all shipping methods except "free shipping" when a cart amount is reached
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );
function my_hide_shipping_when_free_is_available( $rates ) {

    $cart_items_total = WC()->cart->cart_contents_total;

    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
        if ( 'free_shipping' === $rate->method_id && $cart_items_total > 20 ) {
            $free[ $rate_id ] = $rate;
            break;
        }
    }
    return ! empty( $free ) ? $free : $rates;
}
由于付款方式选择在结帐页面的底部,因此,BACS支付网关实现此功能的唯一方法是在BACS客户选择事件上使用ajax
,但这是一种复杂且真实的开发……对于给您带来的不便,我深表歉意