Hi @flannelgraphs
How do I A.
So you must have user role like wholesalersetc. I don’t think you need plugin but by below code might be you will achive that what you want..
Go to wp-content/plugins/WooCommerce/templates/cart directory and look up for cart-totals.php file
Copy this file and go to your theme/child theme, create a folder WooCommerce/cart and paste cart-total.php file here.
The structure will be something like /wp-content/themes/{Your-theme-name}/woocommerce/cart/cart-totals.php
After copy pasting the file, open the file in the editor and look for the code line:
<div class="wc-proceed-to-checkout">
<?php do_action( 'woocommerce_proceed_to_checkout' ); ?>
</div>
Replace the above code with the lines below.
<div class="wc-proceed-to-checkout">
<?php
//Get current user and check the user role.
$current_screen_user = wp_get_current_user();
// In my scenario “wholesale_buyer” is the user role for which I want this validation. You can add your user roles.
if( in_array( 'wholesale_buyer', $current_screen_user->roles ) ) {
$minimum = 300; // Set the minimum amt.
$cart_amt = WC()->cart->subtotal; // cart sub_total, this is actual total excluding discounts and shipping.
if ( $cart_amt < $minimum ) {
if( is_cart() ) {
//Added notices for cart page.
wc_print_notice(
sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price( $minimum ),
wc_price( $cart_amt )
), 'error'
);
} else {
//Added notice msg for checkout page.
wc_add_notice(
sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price( $minimum ),
wc_price( $cart_amt)
), 'error'
);
}
} else {
do_action( 'woocommerce_proceed_to_checkout' );
}
} else {
do_action( 'woocommerce_proceed_to_checkout' );
}
?>
</div>
Note: Please note that you need to change ROLE in above code as per your current setup.
From the above code snippet, we hide the Proceed To Checkout button on cart page and add validations on cart page.
Thanks
Ahir Hemant