{"id":343,"date":"2019-08-29T12:15:51","date_gmt":"2019-08-29T12:15:51","guid":{"rendered":"http:\/\/shaplakanon.com\/wpsupport\/?p=343"},"modified":"2019-08-29T12:15:53","modified_gmt":"2019-08-29T12:15:53","slug":"how-to-set-woocommerce-order-status-based-on-payment-gateway","status":"publish","type":"post","link":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/","title":{"rendered":"How to set woocommerce order status based on payment gateway?"},"content":{"rendered":"\n

There is a woocommerce documentation<\/a> to automatically complete orders. You could also change the \u201cCompleted\u201d status to be another order status, like \u201cProcessing\u201d. The function is following<\/p>\n\n\n\n

\/**\n * Auto Complete all WooCommerce orders.\n *\/\nadd_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );\nfunction custom_woocommerce_auto_complete_order( $order_id ) { \n    if ( ! $order_id ) {\n        return;\n    }\n\n    $order = wc_get_order( $order_id );\n    $order->update_status( 'completed' );\n}<\/pre>\n\n\n\n

Add code to your child theme\u2019s\u00a0functions.php<\/code>\u00a0file or via a plugin that allows custom functions to be added, such as the\u00a0Code snippets<\/a>\u00a0plugin. Avoid adding custom code directly to your parent theme\u2019s\u00a0functions.php<\/code>\u00a0file as this will be wiped entirely when you update the theme. <\/p>\n\n\n\n

One of my clients asked yesterday that they want to automatically complete order for paypal and bitcoin but not for bank transfer since bank transfer take 3-5 days to complete the transactions. so i modified the above code and sharing here if it help anybody. The modified code is following:<\/p>\n\n\n\n

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );\nfunction custom_woocommerce_auto_complete_order( $order_id ) { \n    if ( ! $order_id ) {\n        return;\n    }\n         $payment_title = get_post_meta( $order_id, '_payment_method_title', true );\n\nif($payment_title == 'PayPal'){\n\n    $order = wc_get_order( $order_id );\n    $order->update_status( 'completed' );\n\n} else if($payment_title == 'Bitcoin'){\n    $order = wc_get_order( $order_id );\n    $order->update_status( 'completed' );\n}\n}<\/pre>\n\n\n\n

Change the payment title to your real title. If you need any help, feel free to comment or contact us.<\/p>\n","protected":false},"excerpt":{"rendered":"

There is a woocommerce documentation to automatically complete orders. You could also change the \u201cCompleted\u201d status to be another order<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[98,99],"class_list":["post-343","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-woocommerce","tag-woocommerce-order-status-control"],"yoast_head":"\nHow to set woocommerce order status based on payment gateway? - WordPress Support<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set woocommerce order status based on payment gateway? - WordPress Support\" \/>\n<meta property=\"og:description\" content=\"There is a woocommerce documentation to automatically complete orders. You could also change the \u201cCompleted\u201d status to be another order\" \/>\n<meta property=\"og:url\" content=\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\" \/>\n<meta property=\"og:site_name\" content=\"WordPress Support\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/getwpsupport\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-29T12:15:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-29T12:15:53+00:00\" \/>\n<meta name=\"author\" content=\"Ruhul Amin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:site\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ruhul Amin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\"},\"author\":{\"name\":\"Ruhul Amin\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\"},\"headline\":\"How to set woocommerce order status based on payment gateway?\",\"datePublished\":\"2019-08-29T12:15:51+00:00\",\"dateModified\":\"2019-08-29T12:15:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\"},\"wordCount\":154,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"keywords\":[\"woocommerce\",\"woocommerce order status control\"],\"articleSection\":[\"wordpress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\",\"name\":\"How to set woocommerce order status based on payment gateway? - WordPress Support\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\"},\"datePublished\":\"2019-08-29T12:15:51+00:00\",\"dateModified\":\"2019-08-29T12:15:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/shaplakanon.com\/wpsupport\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to set woocommerce order status based on payment gateway?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"name\":\"WordPress Support\",\"description\":\"Wordpress Repair, migration, speed optimization\",\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\",\"name\":\"WordPress Support\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"contentUrl\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"width\":274,\"height\":55,\"caption\":\"WordPress Support\"},\"image\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/getwpsupport\/\",\"https:\/\/x.com\/ruhul24\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\",\"name\":\"Ruhul Amin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"caption\":\"Ruhul Amin\"},\"sameAs\":[\"https:\/\/shaplakanon.com\/wdc\/\"],\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set woocommerce order status based on payment gateway? - WordPress Support","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/","og_locale":"en_US","og_type":"article","og_title":"How to set woocommerce order status based on payment gateway? - WordPress Support","og_description":"There is a woocommerce documentation to automatically complete orders. You could also change the \u201cCompleted\u201d status to be another order","og_url":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/","og_site_name":"WordPress Support","article_publisher":"https:\/\/facebook.com\/getwpsupport\/","article_published_time":"2019-08-29T12:15:51+00:00","article_modified_time":"2019-08-29T12:15:53+00:00","author":"Ruhul Amin","twitter_card":"summary_large_image","twitter_creator":"@ruhul24","twitter_site":"@ruhul24","twitter_misc":{"Written by":"Ruhul Amin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#article","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/"},"author":{"name":"Ruhul Amin","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825"},"headline":"How to set woocommerce order status based on payment gateway?","datePublished":"2019-08-29T12:15:51+00:00","dateModified":"2019-08-29T12:15:53+00:00","mainEntityOfPage":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/"},"wordCount":154,"commentCount":0,"publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"keywords":["woocommerce","woocommerce order status control"],"articleSection":["wordpress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/","url":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/","name":"How to set woocommerce order status based on payment gateway? - WordPress Support","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#website"},"datePublished":"2019-08-29T12:15:51+00:00","dateModified":"2019-08-29T12:15:53+00:00","breadcrumb":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-set-woocommerce-order-status-based-on-payment-gateway\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/shaplakanon.com\/wpsupport\/"},{"@type":"ListItem","position":2,"name":"How to set woocommerce order status based on payment gateway?"}]},{"@type":"WebSite","@id":"https:\/\/shaplakanon.com\/wpsupport\/#website","url":"https:\/\/shaplakanon.com\/wpsupport\/","name":"WordPress Support","description":"Wordpress Repair, migration, speed optimization","publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization","name":"WordPress Support","url":"https:\/\/shaplakanon.com\/wpsupport\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/","url":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","contentUrl":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","width":274,"height":55,"caption":"WordPress Support"},"image":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/getwpsupport\/","https:\/\/x.com\/ruhul24"]},{"@type":"Person","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825","name":"Ruhul Amin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","caption":"Ruhul Amin"},"sameAs":["https:\/\/shaplakanon.com\/wdc\/"],"url":"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/"}]}},"_links":{"self":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/343"}],"collection":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/comments?post=343"}],"version-history":[{"count":0,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/343\/revisions"}],"wp:attachment":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/media?parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/categories?post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/tags?post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}