15 1 0 4000 1 https://codeblock.co.za 300 true 0

wc_create_order()

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);

Was This Helpful?

Next Post
add_product()

0 Comments

Leave a Reply