commerce icon indicating copy to clipboard operation
commerce copied to clipboard

Shopify wishlist implementation

Open chemmanouilidis opened this issue 2 years ago • 7 comments

Wishlist implementation for the Shopify provider. You can Add, Remove products to your customer wishlist as well as their variants. Also Added the possibility to add a specific product variant to your wishlist if its not available for sale (due to no stock etc)...

  1. changed shopify fetch and graphQL fetch types and also the fetcher functions to include useAdminApiFlag in order to seperate graphql storefront API operations from Admin API ones,

  2. generated shopify admin api schema(documentation for code generation is outdated and not working as per readme instructions - yarn generate:shopify script not present),

  3. changed RemoveItemHook of commerce/types/wishlist,

  4. created shopify wishlist api routes (addItem, removeItem, getWishlist),

  5. added shopify api operation getCustomerWishlist,

  6. updated index files of api/operations, utils and api/wishlist,

  7. created shopify wishlist types ,

  8. created getCustomerId function as a util in shopify ,

  9. added customerUpdate mutation (Admin API operation), customer query (Admin API operation),

  10. added getCustomerId query,

  11. modified commerce wishlist endpoint to extract item variable from req/body,

  12. added useAdminApi flag to commerce fetcherOptions,

  13. updated wishlist api constants,

  14. modified shopify fetcher,

  15. added wishlist handlers to shopify provider ,

  16. Polished frontend UI so that you can now correctly add product to wishlist if variant is not available for sale

  17. modified .env.template files to correctly refer that you also need shopify admin access token

chemmanouilidis avatar Mar 31 '22 16:03 chemmanouilidis

@chemmanouilidis is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 31 '22 16:03 vercel[bot]

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

commerce-local – ./site

🔍 Inspect: https://vercel.com/vercel-solutions-vtest314/commerce-local/4tMM9t6GzHEvFbqwnFRiJJELBWAH
✅ Preview: Failed

[Deployment for e81c0fb failed]

commerce-bigcommerce – ./site

🔍 Inspect: https://vercel.com/vercel-solutions-vtest314/commerce-bigcommerce/J7v1CDEWHcfBgAZGGqm1msGfWepN
✅ Preview: Failed

[Deployment for 594b3ef failed]

commerce-ordercloud – ./site

🔍 Inspect: https://vercel.com/vercel-solutions-vtest314/commerce-ordercloud/2pPXTFgZt6ZQe6FFwmdsXv83TePB
✅ Preview: Failed

vercel[bot] avatar Mar 31 '22 16:03 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
commerce-kibocommerce ❌ Failed (Inspect) Apr 21, 2022 at 8:43AM (UTC)
commerce-local ✅ Ready (Inspect) Visit Preview Apr 21, 2022 at 8:43AM (UTC)

vercel[bot] avatar Apr 20 '22 07:04 vercel[bot]

Corrections Commit includes the following changes:

### Commerce API

  1. reverted commerce/api/endpoints/wishlist & commerce/types/wishlist to source implementation to avoid problems with other providers and major breaking changes

### Shopify provider

  1. Modified shopify/api/endpoints/wishlist/add-item property destructuring to be compatible with the types used,
  2. remove-item also has the same destructuring method plus new filtering method that correctly filters the wishlist by productId AND variantID
  3. Modified shopify/types/wishlist. RemoveItemHook type now correctly extends the core type from commerce/types/wishlist by adding an optional property itemVariantId, modified WishlistSchema type to be compatible with the new functions used in wishlist/endpoints (add-item, remove-item etc) by adding variables type property for the body.
  4. minor changes to use-add-item specifically in the way properties are being handed to the fetcher.
  5. use-remove-item hook now complies with the new types declared passing through itemId and itemVariantId
  6. modified env.template and const files to "hide" admin access token variable.

Site Components

  1. Modified WishlistButton removeItem function to be compatible across all providers
  2. Modified WishlistCard removeItem function (same as above) and also added variant options labels for each product in your wishlist. This all summarizes my goal from the begining being a user should be able to add more variants of the same product in his wishlist and not just the main product. One, can desire both the blue and the red version of that T-Shirt that is currently out of stock in those colors.
  3. Wishlist page midifications are mainly reverts to previous changes I have made. Now wishlist page should be the same as origin.

chemmanouilidis avatar Apr 20 '22 08:04 chemmanouilidis

Thank you for your contribution. It looks awesome and is a lot of work. Please see my comments and requests for changes.

Additional notes:

  • we use yarn for this project, please remove package-lock.json
  • the main "local" build is failing

package lock removed. local build was failing to me because it could not resolve the wishlist hooks from the "local" framework. wishlist folder of local package didn't have an index file with default exports. Should I add it and commit? adding the file to me, solves the problem.

chemmanouilidis avatar Apr 21 '22 07:04 chemmanouilidis

now the main "local" build succeeds.

chemmanouilidis avatar Apr 21 '22 08:04 chemmanouilidis

@chemmanouilidis thanks for this PR. Is there any progress here, did you ever use this in production?

robinglen avatar Aug 12 '22 10:08 robinglen

@chemmanouilidis thanks for this PR. Is there any progress here, did you ever use this in production?

I don't think any further progress is required. I currently use it in production and it seems stable.

chemmanouilidis avatar Sep 27 '22 08:09 chemmanouilidis

Hey there! Thank you for your contribution. We have decided to take Next.js Commerce in a new direction and will be closing out current PRs and issues due to this change. Please see this PR for more details: https://github.com/vercel/commerce/pull/966

leerob avatar Apr 18 '23 02:04 leerob