rajudhaka

Woo-commerce minimum order snippets

Apr 23rd, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /**
  2. * Set a minimum order amount for checkout
  3. */
  4. add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
  5. add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
  6.  
  7. function wc_minimum_order_amount() {
  8. // Set this variable to specify a minimum order value
  9. $minimum = 50;
  10.  
  11. if ( WC()->cart->total < $minimum ) {
  12.  
  13. if( is_cart() ) {
  14.  
  15. wc_print_notice(
  16. sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order ' ,
  17. wc_price( WC()->cart->total ),
  18. wc_price( $minimum )
  19. ), 'error'
  20. );
  21.  
  22. } else {
  23.  
  24. wc_add_notice(
  25. sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order' ,
  26. wc_price( WC()->cart->total ),
  27. wc_price( $minimum )
  28. ), 'error'
  29. );
  30.  
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment