Set WooCommerce order status when order is created from processing to pending










1















When a woocommerce order is created the status of the order is "processing". I need to change the default order-status to "pending".



How can I achieve this?










share|improve this question




























    1















    When a woocommerce order is created the status of the order is "processing". I need to change the default order-status to "pending".



    How can I achieve this?










    share|improve this question


























      1












      1








      1


      1






      When a woocommerce order is created the status of the order is "processing". I need to change the default order-status to "pending".



      How can I achieve this?










      share|improve this question
















      When a woocommerce order is created the status of the order is "processing". I need to change the default order-status to "pending".



      How can I achieve this?







      php wordpress woocommerce status orders






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 31 '17 at 17:58









      LoicTheAztec

      86.5k136399




      86.5k136399










      asked Aug 31 '17 at 15:47









      Peesen87Peesen87

      4901524




      4901524






















          2 Answers
          2






          active

          oldest

          votes


















          7














          The default order status is set by the payment method or the payment gateway.



          You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):



          add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
          function changing_order_status_before_payment( $order_id, $posted_data, $order )
          $order->update_status( 'pending' );



          Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…




          For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
          Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce




          Now instead you can update the order status using woocommerce_thankyou hook:



          add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
          function woocommerce_thankyou_change_order_status( $order_id )
          if( ! $order_id ) return;

          $order = wc_get_order( $order_id );

          if( $order->get_status() == 'processing' )
          $order->update_status( 'pending' );



          Code goes in function.php file of your active child theme (or theme) or also in any plugin file.



          Tested and works




          Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...

          Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.





          Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)






          share|improve this answer
































            -2














            // Rename order status 'Processing' to 'Order Completed' in admin main view - different hook, different value than the other places
            add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
            function wc_renaming_order_status( $order_statuses )
            foreach ( $order_statuses as $key => $status )
            if ( 'wc-processing' === $key )
            $order_statuses['wc-processing'] = _x( 'Order Completed', 'Order status', 'woocommerce' );

            return $order_statuses;






            share|improve this answer






















              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%2f45985488%2fset-woocommerce-order-status-when-order-is-created-from-processing-to-pending%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









              7














              The default order status is set by the payment method or the payment gateway.



              You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):



              add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
              function changing_order_status_before_payment( $order_id, $posted_data, $order )
              $order->update_status( 'pending' );



              Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…




              For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
              Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce




              Now instead you can update the order status using woocommerce_thankyou hook:



              add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
              function woocommerce_thankyou_change_order_status( $order_id )
              if( ! $order_id ) return;

              $order = wc_get_order( $order_id );

              if( $order->get_status() == 'processing' )
              $order->update_status( 'pending' );



              Code goes in function.php file of your active child theme (or theme) or also in any plugin file.



              Tested and works




              Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...

              Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.





              Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)






              share|improve this answer





























                7














                The default order status is set by the payment method or the payment gateway.



                You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):



                add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
                function changing_order_status_before_payment( $order_id, $posted_data, $order )
                $order->update_status( 'pending' );



                Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…




                For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
                Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce




                Now instead you can update the order status using woocommerce_thankyou hook:



                add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
                function woocommerce_thankyou_change_order_status( $order_id )
                if( ! $order_id ) return;

                $order = wc_get_order( $order_id );

                if( $order->get_status() == 'processing' )
                $order->update_status( 'pending' );



                Code goes in function.php file of your active child theme (or theme) or also in any plugin file.



                Tested and works




                Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...

                Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.





                Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)






                share|improve this answer



























                  7












                  7








                  7







                  The default order status is set by the payment method or the payment gateway.



                  You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):



                  add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
                  function changing_order_status_before_payment( $order_id, $posted_data, $order )
                  $order->update_status( 'pending' );



                  Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…




                  For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
                  Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce




                  Now instead you can update the order status using woocommerce_thankyou hook:



                  add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
                  function woocommerce_thankyou_change_order_status( $order_id )
                  if( ! $order_id ) return;

                  $order = wc_get_order( $order_id );

                  if( $order->get_status() == 'processing' )
                  $order->update_status( 'pending' );



                  Code goes in function.php file of your active child theme (or theme) or also in any plugin file.



                  Tested and works




                  Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...

                  Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.





                  Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)






                  share|improve this answer















                  The default order status is set by the payment method or the payment gateway.



                  You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):



                  add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
                  function changing_order_status_before_payment( $order_id, $posted_data, $order )
                  $order->update_status( 'pending' );



                  Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…




                  For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
                  Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce




                  Now instead you can update the order status using woocommerce_thankyou hook:



                  add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
                  function woocommerce_thankyou_change_order_status( $order_id )
                  if( ! $order_id ) return;

                  $order = wc_get_order( $order_id );

                  if( $order->get_status() == 'processing' )
                  $order->update_status( 'pending' );



                  Code goes in function.php file of your active child theme (or theme) or also in any plugin file.



                  Tested and works




                  Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...

                  Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.





                  Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 14 '18 at 1:43

























                  answered Aug 31 '17 at 17:52









                  LoicTheAztecLoicTheAztec

                  86.5k136399




                  86.5k136399























                      -2














                      // Rename order status 'Processing' to 'Order Completed' in admin main view - different hook, different value than the other places
                      add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
                      function wc_renaming_order_status( $order_statuses )
                      foreach ( $order_statuses as $key => $status )
                      if ( 'wc-processing' === $key )
                      $order_statuses['wc-processing'] = _x( 'Order Completed', 'Order status', 'woocommerce' );

                      return $order_statuses;






                      share|improve this answer



























                        -2














                        // Rename order status 'Processing' to 'Order Completed' in admin main view - different hook, different value than the other places
                        add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
                        function wc_renaming_order_status( $order_statuses )
                        foreach ( $order_statuses as $key => $status )
                        if ( 'wc-processing' === $key )
                        $order_statuses['wc-processing'] = _x( 'Order Completed', 'Order status', 'woocommerce' );

                        return $order_statuses;






                        share|improve this answer

























                          -2












                          -2








                          -2







                          // Rename order status 'Processing' to 'Order Completed' in admin main view - different hook, different value than the other places
                          add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
                          function wc_renaming_order_status( $order_statuses )
                          foreach ( $order_statuses as $key => $status )
                          if ( 'wc-processing' === $key )
                          $order_statuses['wc-processing'] = _x( 'Order Completed', 'Order status', 'woocommerce' );

                          return $order_statuses;






                          share|improve this answer













                          // Rename order status 'Processing' to 'Order Completed' in admin main view - different hook, different value than the other places
                          add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
                          function wc_renaming_order_status( $order_statuses )
                          foreach ( $order_statuses as $key => $status )
                          if ( 'wc-processing' === $key )
                          $order_statuses['wc-processing'] = _x( 'Order Completed', 'Order status', 'woocommerce' );

                          return $order_statuses;







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 7 '18 at 5:34









                          akshay dalviakshay dalvi

                          1




                          1



























                              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%2f45985488%2fset-woocommerce-order-status-when-order-is-created-from-processing-to-pending%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

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              政党

                              天津地下鉄3号線