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

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page