The minimum order amount has to be 1500. I use this code to show the message in the cart, and to disable 'proceed to checkout' action, if the amount is less then 1500.
add_action( 'woocommerce_before_cart', 'truemisha_minimum_order_amount' );
function truemisha_minimum_order_amount(){
$minimum_amount = 1500;
if ( WC()->cart->subtotal < $minimum_amount ) {
wc_print_notice(
sprintf(
'The minimum order amount is %s, your order amount is %s.' ,
wc_price( $minimum_amount ),
wc_price( WC()->cart->subtotal )
),
'notice'
);
}
}
add_action( 'woocommerce_before_checkout_form', 'truemisha_minimum_order_amount' );
add_action( 'woocommerce_checkout_process', 'truemisha_no_checkout_min_order_amount' );
function truemisha_no_checkout_min_order_amount() {
$minimum_amount = 1500;
if ( WC()->cart->subtotal < $minimum_amount ) {
wc_add_notice(
sprintf(
'The minimum order amount is %s, your order amount is %s.',
wc_price( $minimum_amount ),
wc_price( WC()->cart->subtotal )
),
'error'
);
}
}
function disable_checkout_button() {
// Set this variable to specify a minimum order value
$minimum = 1500;
$total = WC()->cart->cart_contents_total;
if( $total < $minimum ){
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
echo ' <form><input type="button" style="display: inline-block;" class="checkout-button button alt wc-forward " value="Back to the product" onClick="history.back()">
</form>
<a style="pointer-events: none !important; background: #dfe1f0; border-color: #dfe1f0; color: rgba(51,51,51,.5); cursor: no-drop; display: inline-block;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a><p style="font-weight: bold;">The minimum order amount is<span style="color:red;">'.$minimum.'</span> ₽. </p>';
}
}
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );
I need the same in the product page, for add to cart button - NOT HIDE OR DELETE IT, exactly disable, if the order amount is<1500. What's the right hook for it?