Skip to content

Plans & Intro-Offers: Stop serving introductory offers through plans endpoints. Refactor to make use of wpcom/v2/introductory-offers #93009

Open

Description

I think we got off the wrong starting point with introductory offers: how we serve through the plans' endpoints and compile on the frontend. Unless I am wrong, we've introduced overhead and duplication of state by opting to serve introductory offers through plans' endpoints. It can manifest itself into all sorts of issues if intro offers are accessible through multiple state/endpoint handlers serving potentially different prices each - explain below.

Since building the Woo $1 promo pricing (peapX7-2Dm-p2), we opted to serve the intro offers through /sites/:id/plans endpoint. We later also explored (not sure if the diff was shipped in the end) to serve these similarly through the /plans endpoint for signup flows during the WPCOM intro offers work (pau2Xa-5mX-p2).

The problem with this setup is we already have a dedicated endpoint for these through v2 API: /wpcom/v2/introductory-offers (which applies at the Product level). We briefly chatted about this in Slack and the main reasoning behind serving through plans was (1) not aware of the existence of /introductory-offers state/endpoint, and (2) enabling prorated pricing, which is likely a site&plan-related concern. On the second point, I do not think we prorate the intro offer prices, irrespective. The /introductory-offers endpoint also accepts a site parameter for tailoring the prices in the context of a given site (so proration can happen there - and assuming it can, then there's no need to duplicate the source?).

We intend to un-dupe and centralize plan pricing behind data stores (e.g. #86638). There is already complexity introduced from the above setup. A case I've spotted in the code is JP App plans, which query for introductory offers on both plans and other JP products - they do this through /introductory-offers.

Suggestion

My suggestion is to stick with one source - to remove from plans' endpoints altogether. As far as plans are concerned, they can still be compiled through Plans.usePricingMetaForGridPlans, which is mostly a convenience hook/selector for combining other eligibility conditions.

How

  1. Create an intro-offers slice in @automattic/data-stores with the types and a query hook useIntroductoryOffers
  2. Migrate existing uses to query the data-store
  3. Remove the intro-offers Calypso state altegether
  4. Update Plans.usePlans & Plans.useSitePlans to not compile these at all in the returned objects
  5. Query intro-offers in Plans.usePricingMetaForGridPlans and attach to the pricing objects
  6. Update /plans and /sites/:id/plans endpoints to stop sending introductory offer properties through
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions