更改WooCommerce中虚拟,可下载,免费或缺货产品的订单状态

问题描述 投票:0回答:1

我尝试通过+1检查插件located here进行一些修改因此,对于所有Virtual Downloadable Free(价格= 0,00)及待售产品,我希望Woocommerce将订单状态设置为“处理中”

我在下面的代码中得到的结果-Woocommerce将订单状态设置为“待付款”是否有任何想法如何将其切换为“处理中”:

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;
}
php wordpress woocommerce product orders
1个回答
0
投票

注1:

改用woocommerce_thankyou钩子
© www.soinside.com 2019 - 2024. All rights reserved.