Skip to content

Commit

Permalink
Move to next year when 12 months are added to first payment date (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayisha authored Aug 21, 2024
1 parent de943f2 commit d09267b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** WooCommerce Subscriptions Core Changelog ***

= 7.4.1 - 2024-xx-xx =
* Fix - Add a year to the next renewal date billing interval is 12 months or more for a synced subscription.

= 7.4.0 - 2024-08-16 =
* Dev - Introduce new parameter to WC_Subscription::get_last_order() to enable filtering out orders with specific statuses.
* Update - Schedule subscription-related events with a priority of 1 to allow for earlier execution within the Action Scheduler.
Expand Down
3 changes: 2 additions & 1 deletion includes/class-wc-subscriptions-synchroniser.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,9 @@ public static function calculate_first_payment_date( $product, $type = 'mysql',
$month_number = gmdate( 'm', wcs_add_months( $from_timestamp, $interval ) );
}
}

// when a certain number of months are added and the first payment date moves to next year
if ( $month_number < gmdate( 'm', $from_timestamp ) ) {
if ( $month_number < gmdate( 'm', $from_timestamp ) || $interval >= 12 ) {
$year = gmdate( 'Y', $from_timestamp );
$year++;
$first_payment_timestamp = wcs_strtotime_dark_knight( "{$payment_day} {$month} {$year}", $from_timestamp );
Expand Down

0 comments on commit d09267b

Please sign in to comment.