diff --git a/classes/gateways/class.pmprogateway_stripe.php b/classes/gateways/class.pmprogateway_stripe.php index fcccbd5e2..bab2718de 100644 --- a/classes/gateways/class.pmprogateway_stripe.php +++ b/classes/gateways/class.pmprogateway_stripe.php @@ -1611,6 +1611,7 @@ static function pmpro_checkout_before_change_membership_level( $user_id, $morder if ( empty( $level->trial_limit ) && // Check if there is a trial period. $filtered_trial_period_days === $unfiltered_trial_period_days && // Check if the trial period is the same as the filtered trial period. + empty( $level->profile_start_date ) && // Check if the profile start date set directly on the level is empty. ( ! empty( $initial_payment_amount ) && $initial_payment_amount === $recurring_payment_amount ) // Check if the initial payment and recurring payment prices are the same. ) { // We can combine the initial payment and the recurring payment. diff --git a/includes/checkout.php b/includes/checkout.php index f5c03f1fb..e2dc93c25 100644 --- a/includes/checkout.php +++ b/includes/checkout.php @@ -15,8 +15,14 @@ function pmpro_calculate_profile_start_date( $order, $date_format, $filter = tru // Get the checkout level. $level = $order->getMembershipLevelAtCheckout(); - // Calculate the profile start date. - $profile_start_date = date_i18n( 'Y-m-d H:i:s', strtotime( '+ ' . $level->cycle_number . ' ' . $level->cycle_period ) ); + // If the level already has a profile start date set, use it. Otherwise, calculate it based on the cycle number and period. + if ( ! empty( $level->profile_start_date ) ) { + // Use the profile start date that is already set. + $profile_start_date = date_i18n( 'Y-m-d H:i:s', strtotime( $level->profile_start_date ) ); + } else { + // Calculate the profile start date based on the cycle number and period. + $profile_start_date = date_i18n( 'Y-m-d H:i:s', strtotime( '+ ' . $level->cycle_number . ' ' . $level->cycle_period ) ); + } // Filter the profile start date if needed. if ( $filter ) { @@ -28,13 +34,14 @@ function pmpro_calculate_profile_start_date( $order, $date_format, $filter = tru * to use that format in case we update this code in the future. * * @since 1.4 + * @deprecated TBD Set the 'profile_start_date' property on the checkout level object instead. * * @param string $profile_start_date The profile start date in UTC YYYY-MM-DD HH:MM:SS format. * @param MemberOrder $order The order that the profile start date is being calculated for. * * @return string The profile start date in UTC YYYY-MM-DD HH:MM:SS format. */ - $profile_start_date = apply_filters( 'pmpro_profile_start_date', $profile_start_date, $order ); + $profile_start_date = apply_filters_deprecated( 'pmpro_profile_start_date', array( $profile_start_date, $order ), 'TBD' ); } // Convert $profile_start_date to correct format.