1
如何在我的自定義表單中創建與產品的訂單? 這是我的代碼:Ubercart:以編程方式通過產品創建訂單Drupal 8
$order = Order::create(array(
'uid' => $uid,
'order_status' => uc_order_state_default('post_checkout'),
));
$order->save();
uc_order_comment_save($order->id(), $this->currentUser()->id(), $this->t('Order created by the administration.'), 'admin');
$product = \Drupal\node\Entity\Node::load($nid);
uc_order_product_save($order->id(), $product);
訂單保存....但是,沒有在我的訂單相關的產品。請幫忙!
我使用Drupal 8.3的Ubercart 8.x的-4.0-ALPHA5
我做到了!非常感謝你。 –
我無法在擴展FormBase類的自定義窗體中以編程方式執行此操作。我們需要擴展或使用的任何類? –