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':
add_action('woocommerce_checkout_order_processed', 'handmade_woocommerce_order');
function handmade_woocommerce_order( $order_id )
{
$order = wc_get_order($order_id);
foreach ($order->get_items() as $item_key => $item_values):
$product_id = $item_values->get_product_id(); //get product id
//get prodct settings i.e virtual
$virtual_product = get_post_meta($product_id,'_virtual',true);
$downloadable_product = get_post_meta($product_id,'_downloadable',true);
$product_backordered=backorders_allowed($product_id,'_backorders',true);
$price = get_post_meta($product_id,'_regular_price',true);
$virtuald=get_option('hmade_vd');
if($virtuald=='yes' && $downloadable_product=='yes' && $virtual_product=='yes' && $product_backordered=='yes')
{
if($price=='0.00')
{
$order->update_status( 'processing' );
}
}
endforeach;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…