Generating Ubercart orders programmatically I am trying to generate ubercart orders programmatically in Drupal 8 and am doing it this way:

$order = Order::create(array(
  'uid' =&gt; $uid,
  'order_status' =&gt; uc_order_state_default('in_checkout'),
));
$order-&gt;save();
$product = Drupal::entityTypeManager()-&gt;getStorage('uc_order_product')-&gt;create(array(
  'qty' =&gt; 1,
  'order_id' =&gt; $order-&gt;id(),
  'nid' =&gt; $product_nid,
  'title' =&gt; $product_node-&gt;get('title')-&gt;value,
  'model' =&gt; '1001',
  'cost' =&gt; $product_node-&gt;get('display_price')-&gt;value,

));
$product-&gt;save(); 
uc_order_product_save($order-&gt;id(), $product);
$order-&gt;save();


Can someone please suggest what wrong I am doing here? Do I need to extend to some class in particular? This order is not generated.
I was able to resolve this by adding these to my file:

//for order
use Drupal\Core\Form\FormBase;
use Drupal\uc_order\Entity\Order;
use Drupal\user\Entity\User;
//for products
use Drupal\uc_order\EditableOrderPanePluginBase;
use Drupal\uc_order\Entity\OrderProduct;
use Drupal\uc_order\OrderInterface;