Wordpress (Woocommerce extension) - Create new order programmatically

后端 未结 8 1613
小蘑菇
小蘑菇 2021-01-31 11:29

I want to create a new order programmatically.

Workflow is simple: After submitting simple form, user will be created and along with that, a new order.

I managed

8条回答
  •  -上瘾入骨i
    2021-01-31 11:59

    For creating New order, You will have to create Object of WC_Order, If you working outside WooCommerce or in function.php then, First Define Global $woocommerce variable.

    So, There will be just 2 line of Code.

    global $woocommerce;
    
    $order = new WC_Order( $order_id );
    

    Hope, It will help You.

提交回复
热议问题