Wordpress (Woocommerce extension) - Create new order programmatically

后端 未结 8 1612
小蘑菇
小蘑菇 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条回答
  •  孤独总比滥情好
    2021-01-31 11:40

    in woocommerce WC_Checkout class has a "create_order" method. You can clone WC_Checkout class, give it another name, change the code of the method for your purposes and call like

    include 'path_to_Cloned_WC_Checkout';
    $chk = new Cloned_WC_Checkout();
    $chk->create_order();
    

    in form handler

提交回复
热议问题