{"id":7117879,"date":"2016-02-28T17:34:17","date_gmt":"2016-02-28T17:34:17","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/auto-complete-virtual-orders-depending-on-payment-methods\/"},"modified":"2016-08-31T14:02:39","modified_gmt":"2016-08-31T14:02:39","slug":"auto-complete-virtual-orders-depending-on-payment-methods","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/auto-complete-virtual-orders-depending-on-payment-methods\/","title":{"rendered":"Auto Complete virtual Orders depending on Payment methods"},"content":{"rendered":"<p>Hello,<\/p>\n<p>Normally <strong>woocommerce<\/strong> should autocomplete orders for virtual products. but it doesn&#8217;t and this is a real problem, <strong>even a BUG like<\/strong>. <\/p>\n<p>So at this point you can find 2 helpful things:<br \/>\n<strong>1) A snippet code<\/strong> <em>(that you can find in wooCommerce docs)<\/em>:<\/p>\n<pre><code>\/**\n * Auto Complete all WooCommerce orders.\n *\/\nadd_action( &#039;woocommerce_thankyou&#039;, &#039;custom_woocommerce_auto_complete_order&#039; );\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-&gt;update_status( &#039;completed&#039; );\n}<\/code><\/pre>\n<p>But this snippet does not work for &#8220;BACS&#8221;, &#8220;Pay on delivery&#8221; and &#8220;Cheque&#8221; payment methods. It&#8217;s ok for Paypal and Credit Card gateways payment methods.<\/p>\n<p><strong>2) A plugin : WooCommerce Autocomplete Orders<\/strong><br \/>\nThis plugin works for all payment methods, but not for other Credit Card gateways payment methods.<\/p>\n<p><strong>My question (could be the solution) :<\/strong><br \/>\nUsing (as a base) the wooCommerce snippet in point 1:<br \/>\nHow can i implement conditional code based on payment methods, i mean something like : if the payment methods aren&#8217;t &#8220;BACS&#8221;, &#8220;Pay on delivery&#8221; and &#8220;Cheque&#8221; then apply updated status &#8220;completed&#8221; for paid orders (concerning virtual products).<br \/>\nI am not a wooCommerce mega expert coder, so i haven&#8217;t find yet how to target payment methods in woocommerce orders. <\/p>\n<p>Some help will be very nice.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/woocommerce\/<\/p>\n","protected":false},"template":"","class_list":["post-7117879","topic","type-topic","status-publish","hentry","topic-tag-virtual-products"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7117879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7117879\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7117879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}