Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Set a minimum subtotal amount in Woocommerce cart

//Just Put This Code Into functions.php Of Your Wordpress Site
/**
 * Set a minimum subtotal amount in Woocommerce cart
 */
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );

function wc_minimum_order_amount() {
    // Set this variable to specify a minimum order value
    $minimum = 149000;

    if ( WC()->cart->subtotal < $minimum ) {

        if( is_cart() ) {

            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( WC()->cart->subtotal ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        } else {

            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( WC()->cart->subtotal ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        }
    }

}
Comment

PREVIOUS NEXT
Code Example
Php :: php define array first 10 number 
Php :: PHP strtolower — Make a string lowercase 
Php :: strip non numeric and period php 
Php :: php html to pdf 
Php :: jquery greater than or equal to 
Php :: laravel create session table 
Php :: acf get image id sub_field 
Php :: switch php version ubuntu 20.04 
Php :: $_get and $_post in php 
Php :: Remove prefix on category title 
Php :: How do I change the URL of Add to cart in WooCommerce 
Php :: rewrite url to exclude php extension 
Php :: laravel notification attach file 
Php :: php sort array by longest 
Php :: array push in php 
Php :: html in php 
Php :: laravel exclude field 
Php :: how to assign variable in php 
Php :: array marge in php 
Php :: how to free session variable in php codeigniter 
Php :: json_encode() 
Php :: how to create constant in php 
Php :: php execute a background process 
Php :: close connection pdo 
Php :: middleware command in laravel 
Php :: PHP DateTime Format date time according to a time zone 
Php :: laravel-enum 
Php :: database, counts 
Php :: woocommerce view order details frontend with shortcode 
Php :: laravel basic login 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =