Set a minimum order amount in WooCommerceWoocommerce set minimum order for a specific user roleHow to force minimum charge in Woocommerce, yet not restrict checkout?WooCommerce - Transpose Cart loop in Order loop for pdf invoicesWoocommerce - set a minimum order value per categorySet a minimum amount in Woocommerce cart except for one categoryHow to update total payable amount on checkout page woocommerceAdd Tip input by customer to WooCommerce checkout pageWooCommerce dynamic minimum order amount based feeChange position of “Place order” button Woocommerce CheckoutAdd a percentage to the grand total in WoocommerceRemove conditionally “proceed to checkout” button from minicart in Woocommerce

If infinitesimal transformations commute why dont the generators of the Lorentz group commute?

Closed-form expression for certain product

If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?

What does routing an IP address mean?

Removing files under particular conditions (number of files, file age)

Which one is correct as adjective “protruding” or “protruded”?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Not using 's' for he/she/it

Biological Blimps: Propulsion

It grows, but water kills it

Store Credit Card Information in Password Manager?

Why does the Sun have different day lengths, but not the gas giants?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

What was this official D&D 3.5e Lovecraft-flavored rulebook?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

Is this toilet slogan correct usage of the English language?

Lowest total scrabble score

What should you do when eye contact makes your subordinate uncomfortable?

Are paving bricks differently sized for sand bedding vs mortar bedding?

Open a doc from terminal, but not by its name

How to implement a feedback to keep the DC gain at zero for this conceptual passive filter?

Multiplicative persistence

Delivering sarcasm

How much character growth crosses the line into breaking the character



Set a minimum order amount in WooCommerce


Woocommerce set minimum order for a specific user roleHow to force minimum charge in Woocommerce, yet not restrict checkout?WooCommerce - Transpose Cart loop in Order loop for pdf invoicesWoocommerce - set a minimum order value per categorySet a minimum amount in Woocommerce cart except for one categoryHow to update total payable amount on checkout page woocommerceAdd Tip input by customer to WooCommerce checkout pageWooCommerce dynamic minimum order amount based feeChange position of “Place order” button Woocommerce CheckoutAdd a percentage to the grand total in WoocommerceRemove conditionally “proceed to checkout” button from minicart in Woocommerce













1















I want to have a minimum order amount in my WooCommerce store. The following code is perfectly showing a notice if the amount isn't reached but the checkout is still possible. How to disable checkout-button when the minimum amount isn't reached?



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 = 50;

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'
);













share|improve this question
























  • Try using the woocommerce_check_cart_items hook instead.

    – ArtisticPhoenix
    Mar 7 at 8:00















1















I want to have a minimum order amount in my WooCommerce store. The following code is perfectly showing a notice if the amount isn't reached but the checkout is still possible. How to disable checkout-button when the minimum amount isn't reached?



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 = 50;

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'
);













share|improve this question
























  • Try using the woocommerce_check_cart_items hook instead.

    – ArtisticPhoenix
    Mar 7 at 8:00













1












1








1


1






I want to have a minimum order amount in my WooCommerce store. The following code is perfectly showing a notice if the amount isn't reached but the checkout is still possible. How to disable checkout-button when the minimum amount isn't reached?



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 = 50;

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'
);













share|improve this question
















I want to have a minimum order amount in my WooCommerce store. The following code is perfectly showing a notice if the amount isn't reached but the checkout is still possible. How to disable checkout-button when the minimum amount isn't reached?



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 = 50;

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'
);










php wordpress woocommerce cart checkout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 9:56









LoicTheAztec

94.3k1368108




94.3k1368108










asked Mar 7 at 7:41









Krystian MantheyKrystian Manthey

84425




84425












  • Try using the woocommerce_check_cart_items hook instead.

    – ArtisticPhoenix
    Mar 7 at 8:00

















  • Try using the woocommerce_check_cart_items hook instead.

    – ArtisticPhoenix
    Mar 7 at 8:00
















Try using the woocommerce_check_cart_items hook instead.

– ArtisticPhoenix
Mar 7 at 8:00





Try using the woocommerce_check_cart_items hook instead.

– ArtisticPhoenix
Mar 7 at 8:00












2 Answers
2






active

oldest

votes


















1














To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:



add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
function required_min_cart_subtotal_amount()


Code goes in function.php file of your active child theme (or active theme). Tested and works.




If customer update the cart changing quantities or removing items, The behavior will be updated too.





enter image description here




enter image description here




Related answer: Woocommerce set minimum order for a specific user role






share|improve this answer






























    1














    function disable_checkout_button() 

    // Set this variable to specify a minimum order value
    $minimum = 50;
    $total = WC()->cart->get_cart_subtotal();
    if( $total < $minimum )
    remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
    echo '<a style="pointer-events: none !important;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';



    add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );





    share|improve this answer























    • thanks, this is in general working, but if you then increase cart amount, button is still not working.

      – Krystian Manthey
      Mar 7 at 8:56










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038477%2fset-a-minimum-order-amount-in-woocommerce%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:



    add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
    function required_min_cart_subtotal_amount()


    Code goes in function.php file of your active child theme (or active theme). Tested and works.




    If customer update the cart changing quantities or removing items, The behavior will be updated too.





    enter image description here




    enter image description here




    Related answer: Woocommerce set minimum order for a specific user role






    share|improve this answer



























      1














      To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:



      add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
      function required_min_cart_subtotal_amount()


      Code goes in function.php file of your active child theme (or active theme). Tested and works.




      If customer update the cart changing quantities or removing items, The behavior will be updated too.





      enter image description here




      enter image description here




      Related answer: Woocommerce set minimum order for a specific user role






      share|improve this answer

























        1












        1








        1







        To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:



        add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
        function required_min_cart_subtotal_amount()


        Code goes in function.php file of your active child theme (or active theme). Tested and works.




        If customer update the cart changing quantities or removing items, The behavior will be updated too.





        enter image description here




        enter image description here




        Related answer: Woocommerce set minimum order for a specific user role






        share|improve this answer













        To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:



        add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
        function required_min_cart_subtotal_amount()


        Code goes in function.php file of your active child theme (or active theme). Tested and works.




        If customer update the cart changing quantities or removing items, The behavior will be updated too.





        enter image description here




        enter image description here




        Related answer: Woocommerce set minimum order for a specific user role







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 9:56









        LoicTheAztecLoicTheAztec

        94.3k1368108




        94.3k1368108























            1














            function disable_checkout_button() 

            // Set this variable to specify a minimum order value
            $minimum = 50;
            $total = WC()->cart->get_cart_subtotal();
            if( $total < $minimum )
            remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
            echo '<a style="pointer-events: none !important;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';



            add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );





            share|improve this answer























            • thanks, this is in general working, but if you then increase cart amount, button is still not working.

              – Krystian Manthey
              Mar 7 at 8:56















            1














            function disable_checkout_button() 

            // Set this variable to specify a minimum order value
            $minimum = 50;
            $total = WC()->cart->get_cart_subtotal();
            if( $total < $minimum )
            remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
            echo '<a style="pointer-events: none !important;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';



            add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );





            share|improve this answer























            • thanks, this is in general working, but if you then increase cart amount, button is still not working.

              – Krystian Manthey
              Mar 7 at 8:56













            1












            1








            1







            function disable_checkout_button() 

            // Set this variable to specify a minimum order value
            $minimum = 50;
            $total = WC()->cart->get_cart_subtotal();
            if( $total < $minimum )
            remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
            echo '<a style="pointer-events: none !important;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';



            add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );





            share|improve this answer













            function disable_checkout_button() 

            // Set this variable to specify a minimum order value
            $minimum = 50;
            $total = WC()->cart->get_cart_subtotal();
            if( $total < $minimum )
            remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
            echo '<a style="pointer-events: none !important;" href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';



            add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 7 at 8:24









            mujuonlymujuonly

            2,79111634




            2,79111634












            • thanks, this is in general working, but if you then increase cart amount, button is still not working.

              – Krystian Manthey
              Mar 7 at 8:56

















            • thanks, this is in general working, but if you then increase cart amount, button is still not working.

              – Krystian Manthey
              Mar 7 at 8:56
















            thanks, this is in general working, but if you then increase cart amount, button is still not working.

            – Krystian Manthey
            Mar 7 at 8:56





            thanks, this is in general working, but if you then increase cart amount, button is still not working.

            – Krystian Manthey
            Mar 7 at 8:56

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038477%2fset-a-minimum-order-amount-in-woocommerce%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved