WOO-Commerce|如果购物车中的总金额低于15,则禁用购物车页面中的继续结账按钮

时间:2018-01-07 作者:Mohamed Badawy

我们正在使用woocommerce,如果购物车中的总金额少于15,我们需要禁用结账按钮。

I used this function:

function disable_checkout_button_no_shipping() { 

    $total = WC()->cart->subtotal;
    if( $total < 15 ){
        remove_action( \'woocommerce_proceed_to_checkout\', \'woocommerce_button_proceed_to_checkout\', 20 );
        echo \'<a href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>\';
    }  
}

add_action( \'woocommerce_proceed_to_checkout\', \'disable_checkout_button_no_shipping\', 1 );
这个函数由Patel Jignesh创建,但它不工作!

Our Cart Page total is

1 个回复
SO网友:Khushboo

Try this:

function disable_checkout_button_no_shipping() { 

    $total = WC()->cart->get_cart_subtotal(); // Change made
    if( $total < 15 ){
        remove_action( \'woocommerce_proceed_to_checkout\', \'woocommerce_button_proceed_to_checkout\', 20 );
        echo \'<a href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>\';
    }  
}

add_action( \'woocommerce_proceed_to_checkout\', \'disable_checkout_button_no_shipping\', 1 );
结束

相关推荐