-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: Support for cross selling API #1396
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a990bd4:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it makes the search query lose a bit of sense, but not entirely. After all, you're still searching for related products hahah.
What's the purpose of this pull request?
As the title says, this PR adds support for cross selling API into
@faststore/api
.Cross selling API allow developers to cross and upsell products with "Who say also say", "Who bought also bough" for a given product. To learn more about the API, check the official API docs and the release note
How it works?
We had to possible was for implementing cross selling at
@faststore/api
.The first one consisted in using a schema.org's product field called https://schema.org/isRelatedTo. With this, I'd have to create a new query on our starters and a specific shelf component for displaying cross selling data. I thought it would generate more code in our starters and could lead to some errors, like SSGing shelf data.
The second solution consisted in adding special facets to the existing search query. With this, no new code needs to be done on our starters and all existing tests work. This solution, for me, makes the
Query.search
loose sense a bit, and I thinkQuery.search
could be renamed forQuery.products
in a future PR.I ended up choosing the second solution and made the search query to accept the following new special facets:
These facet accept productId as the facet's value. To query for a cross selling product list, just:
with the following variables:
How to test it?
Perform the aforementioned query and check that product pages on the starters render correctly with the new cross selling shelves
Starters Deploy Preview
References