You are here

public function LicenseSubscription::onSubscriptionRenew in Commerce License 8.2

Acts on a subscription after it has been renewed.

Called before the subscription and next recurring order are saved.

Parameters

\Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription: The subscription.

\Drupal\commerce_order\Entity\OrderInterface $order: The recurring order.

\Drupal\commerce_order\Entity\OrderInterface $next_order: The next recurring order.

Overrides SubscriptionTypeBase::onSubscriptionRenew

File

src/Plugin/Commerce/SubscriptionType/LicenseSubscription.php, line 80

Class

LicenseSubscription
Provides a Commerce Recurring subscription type for use with licenses.

Namespace

Drupal\commerce_license\Plugin\Commerce\SubscriptionType

Code

public function onSubscriptionRenew(SubscriptionInterface $subscription, OrderInterface $order, OrderInterface $next_order) {
  $license = $subscription->license->entity;

  // Change the license's renewed time and save it.
  // Use the subscription's renewed time rather than the current time to
  // ensure the timestamps are in sync.
  $license
    ->setRenewedTime($subscription
    ->getRenewedTime());
  $license
    ->save();
}