Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-06T09:54:41.537Z
Answers.LastActivityDate: 2020-01-06T09:54:41.537Z
Answers.UserDisplayName: José Veríssimo
Body: <p>How can this be done in PHP?  I can't find anything in the docs. </p>
  
Tags: <plugin-development><plugin-craftcommerce><order>
Title: Commerce 1 create a new order programmatically
ThreadText: # 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);
  
  ```
  
  
  ---
  
  