Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Update wpcom_gifting_subscription default value based on plan expiration
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,19 @@ protected function get_wpcom_gifting_subscription_default() {

foreach ( $purchases as $purchase ) {
if ( wpcom_purchase_has_feature( $purchase, \WPCOM_Features::SUBSCRIPTION_GIFTING ) ) {
/*
* We set default value as false when expiration date not match the following:
* - 54 days before the annual plan expiration.
* - 5 days before the monthly plan expiration.
Comment thread
lupus2k marked this conversation as resolved.
Resolved
* This is to match the gifting banner logic.
*/
$days_of_warning = false !== strpos( $purchase->product_slug, 'monthly' ) ? 5 : 54;
$seconds_until_expiration = strtotime( $purchase->expiry_date ) - time();
if ( $seconds_until_expiration >= $days_of_warning * DAY_IN_SECONDS ) {
return false;
}

// We set default to the inverse of auto-renew.
if ( isset( $purchase->auto_renew ) ) {
return ! $purchase->auto_renew;
} elseif ( isset( $purchase->user_allows_auto_renew ) ) {
Expand Down