Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
  2. add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
  3. add_action( 'woocommerce_before_checkout_form' , 'wc_minimum_order_amount' );
  4.  
  5. function wc_minimum_order_amount() {
  6.  
  7.     $minimum = 6;
  8.     $cartqty = WC()->cart->get_cart_contents_count();
  9.        
  10.     $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
  11.   $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>";
  12.  
  13.     if ( $cartqty < $minimum ) {
  14.  
  15.         if( is_cart() ) {
  16.             echo ('<style>.wc-proceed-to-checkout {display:none;}</style>');       
  17.             wc_print_notice( $backtext , 'error');
  18.  
  19.         } else {
  20.             echo ('<style>.wc-proceed-to-checkout {display:none;}</style>');
  21.             wc_print_notice( $backtext , 'error');
  22.         }
  23.     }
  24.     else {
  25.         echo ('<style>.wc-proceed-to-checkout {display:block;}</style>');
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement