Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renewal banner with discount percentage instead of difference #6349

Closed
1 task done
nicomollet opened this issue Dec 21, 2023 · 5 comments · Fixed by #6397
Closed
1 task done

Renewal banner with discount percentage instead of difference #6349

nicomollet opened this issue Dec 21, 2023 · 5 comments · Fixed by #6397
Assignees
Labels
effort: [S] 1-2 days of estimated development time Module: dashboard priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@nicomollet
Copy link
Contributor

In the renewal banner, we need to display the discount as percentage, not in difference value.

Current text is:
Renew with a $xx discount

We need to make it like:
Renew with a x% discount

This can only be done after this other task is done:

@nicomollet nicomollet added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement Module: dashboard priority: low Issues that can wait effort: [XS] < 1 day of estimated development time labels Dec 21, 2023
@remyperona remyperona added effort: [S] 1-2 days of estimated development time and removed needs: grooming effort: [XS] < 1 day of estimated development time labels Jan 15, 2024
@remyperona
Copy link
Contributor

Scope a solution ✅

In inc/Engine/License/Renewal.php

  • Update display_renewal_soon_banner() to display the discount percentage instead of the discount price. Update the texts according to the renewal banner Gdoc.

  • Update display_renewal_expired_banner() to display the discount percentage instead of the discount price. Update the texts according to the renewal banner Gdoc.

  • Update the related unit & integration tests

Estimate the effort ✅

Effort [S]

@Miraeld
Copy link
Contributor

Miraeld commented Jan 16, 2024

Looks okay to me

@nicomollet
Copy link
Contributor Author

nicomollet commented Jan 16, 2024

Additional context about the pricing update:

  • The pricing endpoints pricing-2023.php and pricing.php display the same content
  • The endpoint is back compatible
  • The pricing update is auto scheduled (date condition) on January 26th midnight (see changes below)
  • The discounted value will be correct in the JSON
  • We don't need to calculate the percentage when displaying the discount as a percent
  • Just take the percentage available in the JSON, see details below
  • This plugin change can't be published before the pricing update because the current discount percentage for grandfather is not exactly 20%

Current pricing endpoint JSON data:

{
   "licenses":{
      "single":{
         "prices":{
            "regular":59,
            "sale":41.3,
            "renewal":{
               "is_grandfather":39.2,
               "is_grandmother":49,
               "not_grandfather":59,
               "is_expired":59
            }
         },
         "websites":1
      },
      "plus":{
         "prices":{
            "regular":119,
            "sale":83.30000000000001,
            "from_single":{
               "regular":60,
               "sale":42
            },
            "renewal":{
               "is_grandfather":79.2,
               "is_grandmother":99,
               "not_grandfather":119,
               "is_expired":119
            }
         },
         "websites":3
      },
      "infinite":{
         "prices":{
            "regular":299,
            "sale":209.3,
            "from_single":{
               "regular":240,
               "sale":168
            },
            "from_plus":{
               "regular":180,
               "sale":126
            },
            "renewal":{
               "is_grandfather":199.2,
               "is_grandmother":249,
               "not_grandfather":299,
               "is_expired":299
            }
         },
         "websites":"unlimited"
      }
   },
   "renewals":{
      "extra_days":15,
      "grandfather_date":1640995200,
      "grandmother_date":1672389000,
      "discount_percent":{
         "is_grandfather":20,
         "not_grandfather":0,
         "is_expired":0
      }
   },
   "promo":{
      "name":"Black Friday",
      "discount_percent":30,
      "start_date":1700438400,
      "end_date":1701302399
   }
}

Pricing endpoint after January 26th pricing update:

{
   "licenses":{
      "single":{
         "prices":{
            "regular":59,
            "sale":41.3,
            "renewal":{
               "is_grandfather":47.2,
               "is_grandmother":59,
               "not_grandfather":59,
               "is_expired":59
            }
         },
         "websites":1
      },
      "plus":{
         "prices":{
            "regular":119,
            "sale":83.30000000000001,
            "from_single":{
               "regular":60,
               "sale":42
            },
            "renewal":{
               "is_grandfather":95.2,
               "is_grandmother":119,
               "not_grandfather":119,
               "is_expired":119
            }
         },
         "websites":3
      },
      "infinite":{
         "prices":{
            "regular":299,
            "sale":209.3,
            "from_single":{
               "regular":240,
               "sale":168
            },
            "from_plus":{
               "regular":180,
               "sale":126
            },
            "renewal":{
               "is_grandfather":239.2,
               "is_grandmother":299,
               "not_grandfather":299,
               "is_expired":299
            }
         },
         "websites":"unlimited"
      }
   },
   "renewals":{
      "extra_days":15,
      "grandfather_date":1640995200,
      "grandmother_date":315532800,
      "discount_percent":{
         "is_grandfather":20,
         "not_grandfather":0,
         "is_expired":0
      }
   },
   "promo":{
      "name":"Black Friday",
      "discount_percent":30,
      "start_date":1700438400,
      "end_date":1701302399
   }
}

Discount as a percent

Beware the get_discount_percent function is wrongly called "percent" but returns a value, not a percent.
After the pricing update, we want a discount as a percent.

We don't need to do this anymore:
return isset( $prices->renewal->is_grandfather, $prices->renewal->not_grandfather ) ? $prices->renewal->not_grandfather - $prices->renewal->is_grandfather : 0;

We can simply take the renewal percent from the JSON: available as $renewals['discount_percent']->is_grandfather (=20).
So maybe just:

if ( $renewals['is_grandfather'] ) {
	return $renewals['discount_percent']->is_grandfather;
}

Grandmother status

This status will be disabled.
To be backward compatible and allow the auto-schedule of the update, the grandmother_date was changed to a date in the past.

So the code base of the plugin can probably remove grand mother status now or later.

FYI @piotrbak

@nicomollet
Copy link
Contributor Author

nicomollet commented Jan 25, 2024

If that can help, you can preview the pricing endpoint with this URL (it behaves like if it was January 26th):
https://wp-rocket.me/stat/1.0/wp-rocket/pricing.php?2024pricingupdate ?2024pricingupdate does the trick

@Mai-Saad Mai-Saad added priority: high Issues which should be resolved as quickly as possible and removed priority: low Issues that can wait labels Jan 26, 2024
@nicomollet
Copy link
Contributor Author

For testing purposes: now that the pricing update is live on production (since today), no need to change the pricing endpoint URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: [S] 1-2 days of estimated development time Module: dashboard priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
6 participants