<p>To add orders programmatically, you can do so by using the <code>Commerce_OrderModel</code> class.</p>

<p>Like so:</p>

<pre><code>$order = new Commerce_OrderModel();
$order-&gt;email = 'test@example.com';

// Add your products here and other order info...
// .................

$success = craft()-&gt;commerce_orders-&gt;saveOrder($order);
</code></pre>

CC BY-SA 4.0
2020-01-06T09:54:41.537Z
2020-01-06T09:54:41.537Z
José Veríssimo
<p>How can this be done in PHP?  I can't find anything in the docs. </p>

<plugin-development><plugin-craftcommerce><order>
Commerce 1 create a new order programmatically
# Commerce 1 create a new order programmatically

(Asked by: username_0 on 2019-02-05)

How can this be done in PHP? I can't find anything in the docs.

**Tags:** plugin-development, plugin-craftcommerce, order


---

## 1 answers

### Answer by username_1 on 2020-01-06. Score: 2

To add orders programmatically, you can do so by using the Commerce_OrderModel class.
Like so:
$order = new Commerce_OrderModel();
$order->email = 'test@example.com';

// Add your products here and other order info...
// .................

$success = craft()->commerce_orders->saveOrder($order);


---

