minimum Amount to checkout only for specific product

Question

i am using woocommernce membership and subscription (including extension called “all product subscription”).
i am trying to add some condition over woocommernce subscription plugin where user can only subscription to our product if they have minimum cart amount $300 (USD) otherwise transaction fail.

Edited:
I had found a semi solution for my problem but now i want to set only for specific product. (woocommernce product bundle and subscription). i want user can choose subscription only when they reach least $300.

1 month/s Subscription Minimum amount $300 to checkout
3 month/s Subscription Minimum amount $600 to checkout
6 month/s Subscription Minimum amount $900 to checkout
1 year Subscription Minimum amount $2500 to checkout

/**
 * Set a minimum order amount for checkout
 */
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 = 300;

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

        if( is_cart() ) {

            wc_print_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order ' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        } else {

            wc_add_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        }
    }
}
0
, , Bilz 2 years 2019-11-27T14:07:46-05:00 0 Answers 76 views 0

Leave an answer

Browse
Browse