protected function RecurringOrderManager::createOrder in Commerce Recurring Framework 8
Creates a recurring order for the given subscription.
Parameters
\Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription: The subscription.
\Drupal\commerce_recurring\BillingPeriod $billing_period: The billing period.
Return value
\Drupal\commerce_order\Entity\OrderInterface The created recurring order, unsaved.
3 calls to RecurringOrderManager::createOrder()
- RecurringOrderManager::renewOrder in src/RecurringOrderManager.php 
- Renews the given recurring order.
- RecurringOrderManager::startRecurring in src/RecurringOrderManager.php 
- Starts the recurring process for the given subscription.
- RecurringOrderManager::startTrial in src/RecurringOrderManager.php 
- Starts the trial for the given subscription.
File
- src/RecurringOrderManager.php, line 245 
Class
- RecurringOrderManager
- Provides the default recurring order manager.
Namespace
Drupal\commerce_recurringCode
protected function createOrder(SubscriptionInterface $subscription, BillingPeriod $billing_period) {
  $payment_method = $subscription
    ->getPaymentMethod();
  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $this->entityTypeManager
    ->getStorage('commerce_order')
    ->create([
    'type' => 'recurring',
    'store_id' => $subscription
      ->getStoreId(),
    'uid' => $subscription
      ->getCustomerId(),
    'billing_profile' => $payment_method ? $payment_method
      ->getBillingProfile() : NULL,
    'payment_method' => $payment_method,
    'payment_gateway' => $payment_method ? $payment_method
      ->getPaymentGatewayId() : NULL,
    'billing_period' => $billing_period,
    'billing_schedule' => $subscription
      ->getBillingSchedule(),
  ]);
  return $order;
}