thetrevorharmon / gatsby-theme-shopify-manager

The easiest way to start a Shopify shop on Gatsby.
https://gatsby-theme-shopify-manager.netlify.app/
MIT License
121 stars 11 forks source link

Exposing client via useClient #56

Open schwartzmj opened 4 years ago

schwartzmj commented 4 years ago

What are your thoughts on exposing the ShopifyBuy client via a simple useClient hook? It could look very similar to the current useCart hook.

I think it would be nice to be able to have quick access to certain things like client.product.helpers.variantForOptions (link) which helps you convert a selection of options into a Shopify Variant ID.

I think this could give us an easy hook into more advanced functionality when needed, while still keeping gatsby-theme-shopify simple and tidy in scope.

thetrevorharmon commented 4 years ago

So there is useClientUnsafe, which is a hook that lets you access the buy client (https://gatsbythemeshopifymanager.com/#useclientunsafe). Are you thinking of doing something different than that?

It’s called useClientUnsafe so that the user knows that it falls outside the “normal” scope of the plugin.

schwartzmj commented 4 years ago

I think that's exactly what I'm looking for and it is also a good name for it 😅. Thanks!

If you think it's a good idea, maybe they could be added within the initial listing of the hooks in the docs in their own small subsection? Definitely my fault for overlooking them but I think it could help when referencing the docs.

thetrevorharmon commented 4 years ago

That's not a bad idea. Maybe after the 'main' list, there is a blurb that is something like:

In addition to these hooks, there are two more experimental hooks: ...

Still working on the wording with that. What do you think?

ghost commented 4 years ago

Just getting the links down the page is sufficient. If while in there it'd be a good idea to update the plug-in settings to make it clear false is not the // default for the two plug-in specific options.