将此代码放在当前主题函数中。php文件。
方法1:
add_action( \'woocommerce_check_cart_items\', \'spyr_set_weight_requirements\' );
function spyr_set_weight_requirements() {
if( is_cart() || is_checkout() ) {
global $woocommerce;
$total = WC()->cart->total;
if( $total < 15 ){
wc_add_notice( \'<strong>MAXIMUM CART PRICE 15 FOR CHECKOUT</strong>\',\'error\');
}
}
}
方法:2
function disable_checkout_button_no_shipping() {
$total = WC()->cart->total;
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 );
In First method page redirect checkout but display only message.
方法3:
function disable_checkout_button_no_shipping() {
$total = WC()->cart->total;
if( $total < 15 ){
remove_action( \'woocommerce_proceed_to_checkout\', \'woocommerce_button_proceed_to_checkout\', 20 );
}
}
add_action( \'woocommerce_proceed_to_checkout\', \'disable_checkout_button_no_shipping\', 99 );