You are here

public function Subscription::getCurrentBillingPeriod in Commerce Recurring Framework 8

Gets the billing period value object for the current order.

Return value

\Drupal\commerce_recurring\BillingPeriod|null The billing period object, or null if not set.

Overrides SubscriptionInterface::getCurrentBillingPeriod

File

src/Entity/Subscription.php, line 576

Class

Subscription
Defines the subscription entity.

Namespace

Drupal\commerce_recurring\Entity

Code

public function getCurrentBillingPeriod() {
  if ($current_order = $this
    ->getCurrentOrder()) {
    if (!$current_order
      ->get('billing_period')
      ->isEmpty()) {
      return $current_order
        ->get('billing_period')
        ->first()
        ->toBillingPeriod();
    }
  }
  return NULL;
}