{"id":3641,"date":"2022-07-23T21:18:30","date_gmt":"2022-07-23T21:18:30","guid":{"rendered":"https:\/\/scriptfeeds.com\/blog\/?p=3641"},"modified":"2023-10-31T20:01:33","modified_gmt":"2023-10-31T20:01:33","slug":"how-to-add-and-edit-custom-order-status-in-woocommerce","status":"publish","type":"post","link":"https:\/\/scriptfeeds.com\/blog\/wordpress\/how-to-add-and-edit-custom-order-status-in-woocommerce\/","title":{"rendered":"Easy steps to add and edit custom order status in WooCommerce"},"content":{"rendered":"\n<p>Recently we added an extra  custom order status in WooCommerce Products for one of our client. These custom order status are very helpful to provide clarity of order status for the customers.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#add-below-code-to-create-new-custom-order-status-in-woo-commerce-orders\">Add below code to create new custom order status in WooCommerce orders.<\/a><\/li><li><a href=\"#add-below-code-to-remove-any-order-status-in-woo-commerce-orders\">Add below code to remove any order status in WooCommerce orders.<\/a><\/li><li><a href=\"#you-can-also-edit-an-existing-order-status-on-woo-commerce\">You can also Edit an existing order status on WooCommerce<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<p>By default, WooCommerce offers some predefined order status but we can add more order status with the help of codes which we gonna provide you. You can set these custom order status in WooCommerce status as per your choice which will be visible to the customers. So lets quickly jumps code section.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Please note that you have to add these codes in functions.php file of your child theme in WordPress<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"418\" height=\"304\" src=\"https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce.jpeg\" alt=\"custom order status in WooCommerce\" class=\"wp-image-4126\" srcset=\"https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce.jpeg 418w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce-221x161.jpeg 221w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce-111x81.jpeg 111w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce-399x290.jpeg 399w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2023\/10\/Custom-order-status-in-woocommerce-120x86.jpeg 120w\" sizes=\"(max-width: 418px) 100vw, 418px\" \/><\/figure>\n\n\n\n<p>WooCommerce orders are treated as a special custom post type. so in order to include our custom order status in WooCommerce order status in the available status list, we need to use the\u00a0<code><strong>register_post_status()<\/strong><\/code>\u00a0WP inbuilt function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-medium-font-size\" id=\"add-below-code-to-create-new-custom-order-status-in-woo-commerce-orders\"><strong>Add below code to create new custom order status in <a href=\"https:\/\/scriptfeeds.com\/blog\/category\/wordpress\/woocommerce\/\">WooCommerce <\/a>orders.<\/strong><\/h2>\n\n\n\n<p>Here we are creating new order status<strong> &#8220;approve&#8221;. <\/strong>you can define any text or label.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Register new status\nfunction register_approve_order_status() {\nregister_post_status( 'wc-approve', array(\n'label'                     =&gt; 'approve',\n'public'                    =&gt; true,\n'show_in_admin_status_list' =&gt; true,\n'show_in_admin_all_list'    =&gt; true,\n'exclude_from_search'       =&gt; false,\n'label_count'               =&gt; _n_noop( 'approve (%s)', 'approve (%s)' )\n) );\n}\n\/\/ Add custom status to order status list\nfunction add_approve_order_statuses( $order_statuses ) {\n$new_order_statuses = array();\nforeach ( $order_statuses as $key =&gt; $status ) {\n$new_order_statuses&#91; $key ] = $status;\nif ( 'wc-on-hold' === $key ) {\n$new_order_statuses&#91;'wc-approve'] = 'approve';\n}\n}\nreturn $new_order_statuses;\n}\nadd_action( 'init', 'register_approve_order_status' );\nadd_filter( 'wc_order_statuses', 'add_approve_order_statuses' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-medium-font-size\" id=\"add-below-code-to-remove-any-order-status-in-woo-commerce-orders\"><strong>Add below code to remove any order status in <a href=\"https:\/\/wordpress.org\/plugins\/woocommerce\/\" data-type=\"link\" data-id=\"https:\/\/wordpress.org\/plugins\/woocommerce\/\" target=\"_blank\" rel=\"noopener\">WooCommerce<\/a> orders.<\/strong><\/h2>\n\n\n\n<p>Use the following script in order to remove an existing order status. This will work for both default order statuses and for custom order status in WooCommerce<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function scriptfeeds_remove_status( $statuses ) {\nif( isset( $statuses&#91;'wc-refunded'] ) ){\nunset( $statuses&#91;'wc-refunded'] );\n}\nreturn $statuses;\n}\nadd_filter( 'wc_order_statuses', 'scriptfeeds_remove_status' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-medium-font-size\" id=\"you-can-also-edit-an-existing-order-status-on-woo-commerce\"><strong>You can also Edit an existing order status on <a href=\"https:\/\/scriptfeeds.com\/blog\/category\/wordpress\/woocommerce\/\">WooCommerce<\/a><\/strong><\/h2>\n\n\n\n<p>The following sample code will edit two order stats: \u201cprocessing\u201d and \u201ccompleted\u201d, changing them to \u201cin progress\u201d and \u201cdelivered\u201d:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function scriptfeeds_rename_status( $order_statuses ) {\nforeach ( $order_statuses as $key =&gt; $status ) {\nif ( 'wc-processing' === $key ) {\n$order_statuses&#91;'wc-processing'] = _x( 'In progress', 'Order status', 'woocommerce' );\n}\nif ( 'wc-completed' === $key ) {\n$order_statuses&#91;'wc-completed'] = _x( 'Delivered', 'Order status', 'woocommerce' );\n}\n}\nreturn $order_statuses;\n}\nadd_filter( 'wc_order_statuses', 'scriptfeeds_rename_status' );<\/code><\/pre>\n\n\n\n<p>So that&#8217;s how you can edit, create or delete any WooCommerce order status. So give it a try and let us know how it goes in the comments. If you need any more customization regarding WooCommerce order status, please let us know in comment section or fill the form below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently we added an extra custom order status in WooCommerce Products for one of our client. These custom order status are very helpful to provide clarity of order status for the customers. By default, WooCommerce offers some predefined order status but we can add more order status with the help of codes which we gonna [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3393,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":{"subtitle":"","format":"standard","video":"","gallery":"","source_name":"","source_url":"","via_name":"","via_url":"","override_template":"0","override":[{"template":"2","single_blog_custom":"","parallax":"1","fullscreen":"1","layout":"right-sidebar","sidebar":"default-sidebar","second_sidebar":"default-sidebar","sticky_sidebar":"1","share_position":"float","share_float_style":"share-monocrhome","show_share_counter":"1","show_view_counter":"1","show_featured":"1","show_post_meta":"1","show_post_author":"1","show_post_author_image":"1","show_post_date":"1","post_date_format":"default","post_date_format_custom":"Y\/m\/d","show_post_category":"1","show_post_reading_time":"0","post_reading_time_wpm":"300","show_zoom_button":"0","zoom_button_out_step":"2","zoom_button_in_step":"3","show_post_tag":"1","show_prev_next_post":"0","show_popup_post":"0","number_popup_post":"1","show_author_box":"0","show_post_related":"1","show_inline_post_related":"0"}],"override_image_size":"0","image_override":[{"single_post_thumbnail_size":"no-crop","single_post_gallery_size":"crop-500"}],"trending_post":"0","trending_post_position":"meta","trending_post_label":"Trending","sponsored_post":"0","sponsored_post_label":"Sponsored by","sponsored_post_name":"","sponsored_post_url":"","sponsored_post_logo_enable":"0","sponsored_post_logo":"","sponsored_post_desc":"","disable_ad":"0"},"jnews_primary_category":{"id":"","hide":""},"footnotes":""},"categories":[75,86],"tags":[232,234,233],"class_list":["post-3641","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-woocommerce","tag-add-custom-woocommerce-order-status","tag-edit-woocommerce-order-status","tag-remove-woocommerce-order-status"],"_links":{"self":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/comments?post=3641"}],"version-history":[{"count":0,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3641\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media\/3393"}],"wp:attachment":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media?parent=3641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/categories?post=3641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/tags?post=3641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}