Skip to content
Advertisement

Change order status for virtual, downloadable, free or backorder products in WooCommerce

i try to slightly modify with +1 check for plugin located here So , for all Virtual Downloadable Free (price=0,00) & on Backorder products I want Woocommerce to set order status ‘Processing’

the result I have with code below – Woocommerce to set order status ‘Pending Payment’ Are there any ideas how to switch it to ‘Processing’:

JavaScript

Advertisement

Answer

Note 1: use woocommerce_thankyou hook instead


Note 2: To know whether a product is virtual or downloadable you can use the following functions $product->is_virtual(); and $product->is_downloadable(); opposite get_post_meta();

More info: https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html


Note 3: It is better not to perform operations in a foreach loop, use a check afterwards

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement