Set a minimum order amount in WooCommerce2019 Community Moderator ElectionWoocommerce 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

PTIJ: Why can't I eat anything?

Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?

Unreachable code, but reachable with exception

Am I not good enough for you?

Is there any way to damage Intellect Devourer(s) when already within a creature's skull?

Is there an elementary proof that there are infinitely many primes that are *not* completely split in an abelian extension?

What is the likely impact of grounding an entire aircraft series?

Set and print content of environment variable in cmd.exe subshell?

Why is Beresheet doing a only a one-way trip?

If the Captain's screens are out, does he switch seats with the co-pilot?

Why would one plane in this picture not have gear down yet?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Is Gradient Descent central to every optimizer?

What wound would be of little consequence to a biped but terrible for a quadruped?

In the late 1940’s to early 1950’s what technology was available that could melt a LOT of ice?

Is there an equal sign with wider gap?

Do I really need to have a scientific explanation for my premise?

Who deserves to be first and second author? PhD student who collected data, research associate who wrote the paper or supervisor?

Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?

Is it true that real estate prices mainly go up?

Finding algorithms of QGIS commands?

Aliens englobed the Solar System: will we notice?

Should QA ask requirements to developers?

Offered promotion but I'm leaving. Should I tell?



Set a minimum order amount in WooCommerce



2019 Community Moderator ElectionWoocommerce 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








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

92.2k1366106




92.2k1366106










asked Mar 7 at 7:41









Krystian MantheyKrystian Manthey

71424




71424












  • 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()
// Only run in the Cart or Checkout pages
if( is_cart()


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()
    // Only run in the Cart or Checkout pages
    if( is_cart()


    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()
      // Only run in the Cart or Checkout pages
      if( is_cart()


      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()
        // Only run in the Cart or Checkout pages
        if( is_cart()


        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()
        // Only run in the Cart or Checkout pages
        if( is_cart()


        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

        92.2k1366106




        92.2k1366106























            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,46011332




            2,46011332












            • 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

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229