wc_create_order()
14th January 2021
0 Comments
Framework / CMS
WooCommerce [Version: Since 3.3.0]
Syntax
Typical Usage
Creating new WooCommerce orders programmatically.
Accepted Parameters
- $args (array) (Optional): The default order arguments you wish to override.
Return Value(s)
Returns a new order object on success which can then be used to add additional data.Notes
Arguments you may override include:
- customer_id
- status
- customer_note
- parent
- created_via
- cart_hash
- order_id
Examples of wc_create_order()
Example 1
<?php
$user_id = get_current_user_id();
$args = array(
'customer_id' => $user_id,
'status' => 'on-hold',
'customer_note' => 'Your order is on hold.',
'parent' => '1234',
'created_via' => 'Promotion Page',
'cart_hash' => '
6516s1fv61asd21f6a5a1vad651d651v651asd',
'order_id' =>
'1234'
);
$new_order = wc_create_order($args);
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.