Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
- add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
- add_action( 'woocommerce_before_checkout_form' , 'wc_minimum_order_amount' );
- function wc_minimum_order_amount() {
- $minimum = 6;
- $cartqty = WC()->cart->get_cart_contents_count();
- $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
- $backtext = "<a style='color: white;' id='cartbackbutton' href='$url'>Hi there, We have a minimum order quatity of 6 jars, please click here to pop back and choose $cartqty more jars of yumminess.</a>";
- if ( $cartqty < $minimum ) {
- if( is_cart() ) {
- echo ('<style>.wc-proceed-to-checkout {display:none;}</style>');
- wc_print_notice( $backtext , 'error');
- } else {
- echo ('<style>.wc-proceed-to-checkout {display:none;}</style>');
- wc_print_notice( $backtext , 'error');
- }
- }
- else {
- echo ('<style>.wc-proceed-to-checkout {display:block;}</style>');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement