Wordpress (Woocommerce extension) - Create new order programmatically

后端 未结 8 1740
小蘑菇
小蘑菇 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:47

    Unfortunately, I don't think there are no easy way to do this I'm afraid.

    You need to add the order post using wp_insert_post(); and then add all the meta data using update_post_meta(). You then need to add the using woocommerce_add_order_item() and woocommerce_add_order_item_meta(). Lasty you need to set the order status using wp_set_object_terms().

    It's quite a lot of steps and pitfalls. You need to check your database carefully and add all the data and meta data you need to process and complete the order.

提交回复
热议问题