I am trying to generate ubercart orders programmatically in Drupal 8 and am doing it this way:
$order = Order::create(array( 'uid' => $uid, 'order_status' => uc_order_state_default('in_checkout'), )); $order->save(); $product = Drupal::entityTypeManager()->getStorage('uc_order_product')->create(array( 'qty' => 1, 'order_id' => $order->id(), 'nid' => $product_nid, 'title' => $product_node->get('title')->value, 'model' => '1001', 'cost' => $product_node->get('display_price')->value, )); $product->save(); uc_order_product_save($order->id(), $product); $order->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.
Sponsored by SupremePR