From 5771940c7c4f477300e9eb61ff97fe4f4059a5fe Mon Sep 17 00:00:00 2001 From: Michael Lee <38788055+jeawhanlee@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:54:42 +0100 Subject: [PATCH] Closes #6349: Update renewal banner with discount percentage instead of difference (#6397) --- inc/Engine/License/Renewal.php | 10 +++------- .../License/views/renewal-expired-banner-ocd.php | 6 +++--- .../Renewal/displayRenewalExpiredBanner.php | 16 ++++++++-------- .../License/Renewal/displayRenewalSoonBanner.php | 12 ++++++------ .../Subscriber/displayRenewalSoonBanner.php | 8 ++++---- 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/inc/Engine/License/Renewal.php b/inc/Engine/License/Renewal.php index a589eed264..a3dbc6e97a 100644 --- a/inc/Engine/License/Renewal.php +++ b/inc/Engine/License/Renewal.php @@ -68,7 +68,7 @@ public function display_renewal_soon_banner() { $data = $this->get_banner_data(); $data['countdown'] = $this->get_countdown_data(); - $discount = esc_html( '$' . number_format_i18n( $this->get_discount_percent(), 2 ) ); + $discount = esc_html( $this->get_discount_percent() . '%' ); $price = esc_html( '$' . number_format_i18n( $this->get_price(), 2 ) ); $data['message'] = sprintf( @@ -152,7 +152,7 @@ public function display_renewal_expired_banner() { esc_html__( 'Renew your license for 1 year now and get %1$s%3$s OFF%2$s immediately: you will only pay %1$s%4$s%2$s!', 'rocket' ), '', '', - esc_html( '$' . number_format_i18n( $this->get_discount_percent(), 2 ) ), + esc_html( $this->get_discount_percent() . '%' ), $price ); } @@ -325,11 +325,7 @@ private function get_discount_percent() { $prices = $prices->prices; if ( $renewals['is_grandfather'] ) { - return isset( $prices->renewal->is_grandfather, $prices->renewal->not_grandfather ) ? $prices->renewal->not_grandfather - $prices->renewal->is_grandfather : 0; - } - - if ( $renewals['is_grandmother'] ) { - return isset( $prices->renewal->is_grandmother, $prices->renewal->not_grandfather ) ? $prices->renewal->not_grandfather - $prices->renewal->is_grandmother : 0; + return $renewals['discount_percent']->is_grandfather; } return 0; diff --git a/inc/Engine/License/views/renewal-expired-banner-ocd.php b/inc/Engine/License/views/renewal-expired-banner-ocd.php index de470fadbb..5aad300ed6 100644 --- a/inc/Engine/License/views/renewal-expired-banner-ocd.php +++ b/inc/Engine/License/views/renewal-expired-banner-ocd.php @@ -8,11 +8,11 @@ defined( 'ABSPATH' ) || exit; ?>
-

+

- , %2$s = . esc_html__( 'You need an %1$sactive license to continue optimizing your CSS delivery%2$s.', 'rocket' ), @@ -26,7 +26,7 @@ , %2$s = , %3$s = date. - esc_html__( 'They will be %1$sautomatically disabled on %3$s%2$s.', 'rocket' ), + esc_html__( 'These features will be %1$sautomatically disabled on %3$s%2$s.', 'rocket' ), '', '', esc_html( $data['disabled_date'] ) diff --git a/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalExpiredBanner.php b/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalExpiredBanner.php index 2705bb524e..0bfa533b52 100644 --- a/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalExpiredBanner.php +++ b/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalExpiredBanner.php @@ -36,7 +36,7 @@ 'renewals' => json_decode( json_encode( [ 'extra_days'=> 15, 'grandfather_date'=> 1640995200, - 'grandmother_date'=> 1672531200, + 'grandmother_date'=> 315532800, 'discount_percent'=> [ 'is_grandfather' => 20, 'not_grandfather'=> 0, @@ -95,7 +95,7 @@ 'template' => 'renewal-expired-banner-ocd', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $19.8 OFF immediately: you will only pay $39.2!', + 'message' => 'Renew your license for 1 year now and get 20% OFF immediately: you will only pay $39.2!', 'disabled_date' => strtotime( 'now + 5 days' ), ], ], @@ -119,7 +119,7 @@ 'template' => 'renewal-expired-banner-ocd', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $10 OFF immediately: you will only pay $49!', + 'message' => 'Renew your license for 1 year now at $59.', 'disabled_date' => strtotime( 'now + 5 days' ), ], ], @@ -184,7 +184,7 @@ 'template' => 'renewal-expired-banner-ocd', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $19.8 OFF immediately: you will only pay $39.2!', + 'message' => 'Renew your license for 1 year now and get 20% OFF immediately: you will only pay $39.2!', 'disabled_date' => strtotime( 'now + 5 days' ), ], ], @@ -278,7 +278,7 @@ 'template' => 'renewal-expired-banner', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $19.8 OFF immediately: you will only pay $39.2!', + 'message' => 'Renew your license for 1 year now and get 20% OFF immediately: you will only pay $39.2!', ], ], ], @@ -301,7 +301,7 @@ 'template' => 'renewal-expired-banner', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $10 OFF immediately: you will only pay $49!', + 'message' => 'Renew your license for 1 year now at $59.', ], ], ], @@ -387,7 +387,7 @@ 'template' => 'renewal-expired-banner', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $19.8 OFF immediately: you will only pay $39.2!', + 'message' => 'Renew your license for 1 year now and get 20% OFF immediately: you will only pay $39.2!', ], ], ], @@ -410,7 +410,7 @@ 'template' => 'renewal-expired-banner', 'data' => [ 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', - 'message' => 'Renew your license for 1 year now and get $10 OFF immediately: you will only pay $49!', + 'message' => 'Renew your license for 1 year now at $59.', ], ], ], diff --git a/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalSoonBanner.php b/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalSoonBanner.php index 0738a89edc..aba464b13d 100644 --- a/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalSoonBanner.php +++ b/tests/Fixtures/inc/Engine/License/Renewal/displayRenewalSoonBanner.php @@ -36,7 +36,7 @@ 'renewals' => json_decode( json_encode( [ 'extra_days'=> 90, 'grandfather_date'=> 1567296000, - 'grandmother_date'=> 1672389000, + 'grandmother_date'=> 315532800, 'discount_percent'=> [ 'is_grandfather' => 20, 'not_grandfather'=> 0, @@ -118,7 +118,7 @@ ], 'expected' => [ 'countdown' => $countdown, - 'message' => 'Renew with a $9.8 discount before it is too late, you will only pay $24.5!', + 'message' => 'Renew before it is too late, you will only pay $34.3!', 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', ], ], @@ -135,7 +135,7 @@ 'pricing' => $pricing, ], 'expected' => [ - 'message' => 'Renew with a $9.8 discount before it is too late, you will only pay $24.5!', + 'message' => 'Renew with a 20% discount before it is too late, you will only pay $24.5!', 'countdown' => $countdown, 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', @@ -173,7 +173,7 @@ ], 'expected' => [ 'countdown' => $countdown, - 'message' => 'Renew with a $19.8 discount before it is too late, you will only pay $49.5!', + 'message' => 'Renew with a 20% discount before it is too late, you will only pay $49.5!', 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', ], ], @@ -191,7 +191,7 @@ ], 'expected' => [ 'countdown' => $countdown, - 'message' => 'Renew with a $49.8 discount before it is too late, you will only pay $124.5!', + 'message' => 'Renew before it is too late, you will only pay $174.3!', 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', ], ], @@ -227,7 +227,7 @@ ], 'expected' => [ 'countdown' => $countdown, - 'message' => 'Renew with a $49.8 discount before it is too late, you will only pay $124.5!', + 'message' => 'Renew with a 20% discount before it is too late, you will only pay $124.5!', 'renewal_url' => 'https://wp-rocket.me/checkout/renew/roger@wp-rocket.me/da5891162a3bc2d8a9670267fd07c9eb/', ], ], diff --git a/tests/Fixtures/inc/Engine/License/Subscriber/displayRenewalSoonBanner.php b/tests/Fixtures/inc/Engine/License/Subscriber/displayRenewalSoonBanner.php index 9abb8b97d6..da574986a1 100644 --- a/tests/Fixtures/inc/Engine/License/Subscriber/displayRenewalSoonBanner.php +++ b/tests/Fixtures/inc/Engine/License/Subscriber/displayRenewalSoonBanner.php @@ -38,7 +38,7 @@ 'renewals' => [ 'extra_days'=> 90, 'grandfather_date'=> 1567296000, - 'grandmother_date'=> 1672389000, + 'grandmother_date'=> 315532800, 'discount_percent'=> [ 'is_grandfather' => 20, 'not_grandfather'=> 0, @@ -133,7 +133,7 @@ Your WP Rocket license is about to expire: you will soon lose access to product updates and support.

- Renew with a $9.80 discount before it is too late, you will only pay $24.50! + Renew with a 20% discount before it is too late, you will only pay $24.50!

@@ -193,7 +193,7 @@ Your WP Rocket license is about to expire: you will soon lose access to product updates and support.

- Renew with a $19.80 discount before it is too late, you will only pay $49.50! + Renew with a 20% discount before it is too late, you will only pay $49.50!

@@ -254,7 +254,7 @@ Your WP Rocket license is about to expire: you will soon lose access to product updates and support.

- Renew with a $49.80 discount before it is too late, you will only pay $124.50! + Renew with a 20% discount before it is too late, you will only pay $124.50!