|
/** |
|
* Get periods created. |
|
* |
|
* @return int |
|
*/ |
|
public function get_periods_created() { |
|
$next_date = $this->subscription->get_next_payment_date(); |
|
|
|
if ( null === $next_date ) { |
|
return 0; |
|
} |
|
|
|
$period = new \DatePeriod( |
|
new \DateTimeImmutable( $this->start_date->format( 'Y-m-d 00:00:00' ) ), |
|
$this->interval, |
|
new \DateTimeImmutable( $next_date->format( 'Y-m-d 00:00:00' ) ) |
|
); |
|
|
|
return \iterator_count( $period ); |
|
} |
The next payment date can go far beyond the end date of a subscription phase.
Should we add something like this?
if ( null !== $this->end_date ) {
$next_date = \min( $next_date, $this->end_date );
}
Probably also rename the variable $next_date to $anchor_date or $pointer_date?
CC @rvdsteege
wp-pay-core/src/Subscriptions/SubscriptionPhase.php
Lines 293 to 312 in bd197f4
The next payment date can go far beyond the end date of a subscription phase.
Should we add something like this?
Probably also rename the variable
$next_dateto$anchor_dateor$pointer_date?CC @rvdsteege