protected function SubscriptionTypeBase::adjustTrialPeriod in Commerce Recurring Framework 8
Adjusts the trial period to reflect the trial end date.
There is no need to adjust the start date because trial periods are always rolling.
Parameters
\Drupal\commerce_recurring\BillingPeriod $trial_period: The trial period.
\Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription: The subscription.
Return value
\Drupal\commerce_recurring\BillingPeriod The adjusted trial period.
1 call to SubscriptionTypeBase::adjustTrialPeriod()
- SubscriptionTypeBase::collectTrialCharges in src/
Plugin/ Commerce/ SubscriptionType/ SubscriptionTypeBase.php - Collects charges for a subscription's trial period.
File
- src/
Plugin/ Commerce/ SubscriptionType/ SubscriptionTypeBase.php, line 168
Class
- SubscriptionTypeBase
- Defines the subscription base class.
Namespace
Drupal\commerce_recurring\Plugin\Commerce\SubscriptionTypeCode
protected function adjustTrialPeriod(BillingPeriod $trial_period, SubscriptionInterface $subscription) {
$trial_end_date = $subscription
->getTrialEndDate();
$end_date = $trial_period
->getEndDate();
if ($trial_end_date && $trial_period
->contains($trial_end_date)) {
// The trial ended before the end of the trial period.
$end_date = $trial_end_date;
}
return new BillingPeriod($trial_period
->getStartDate(), $end_date);
}