项目作者: iamskok

项目描述 :
Add Storefront Visibility Metafields 🛍
高级语言: JavaScript
项目地址: git://github.com/iamskok/gatsby-plugin-shopify-metafields.git



Gatsby


gatsby-plugin-shopify-metafields

Plugin to add Storefront Visibility Metafields via Shopify Admin API. This plugin makes metafields property accessable via Shopify Storefront API.

You can use the Storefront API to read metafields for products and product variants. Metafields are useful for storing specialized information, such as part numbers or additional variant options. The Storefront API lets you access and use that data on the custom storefront.

More in-depth explanation can be found in Retrieving metafields from Storefront API.

Install

  1. yarn add gatsby-plugin-shopify-metafields

How to use

  1. {
  2. resolve: `gatsby-plugin-shopify-metafields`,
  3. options: {
  4. // The domain name of your Shopify shop. This is required.
  5. // Example: 'gatsby-shopify' if your Shopify address is
  6. // 'gatsby-shopify.myshopify.com'.
  7. shopName: `gatsby-shop`,
  8. // An Admin API Key to your Shopify shop. This is required.
  9. // You can generate an access token in the "Manage private apps" section
  10. // of your shop's Apps settings.
  11. // See: https://help.shopify.com/en/api/graphql-admin-api/getting-started#authentication
  12. adminAPIKey: `03h7545db6f32a0dd1b0agupje551970`,
  13. // An Admin API Password to your Shopify shop. This is required.
  14. adminPassword: `47u3929dubj32489dhbbsahdjasdgjas`,
  15. // A list of MetafieldStorefrontVisibility records to whitelist.
  16. // It's a good practice to keep the list of metafields in a separate
  17. // 'json' file and require it in 'gatsby-config.js' to keep it concise.
  18. inputs: [
  19. {
  20. "namespace": "global",
  21. "key": "featured",
  22. "ownerType": "PRODUCT"
  23. },
  24. {
  25. "namespace": "spain",
  26. "key": "sale",
  27. "ownerType": "COLLECTION"
  28. },
  29. ...
  30. ],
  31. // Set verbose to true to display a warning or an error output.
  32. // This prints which MetafieldStorefrontVisibility record.
  33. // was already whitelisted or if there is an error
  34. // Defaults to true.
  35. verbose: true,
  36. // Disable plugin.
  37. // In most scenarios MetafieldStorefrontVisibility has to be whitelisted just once.
  38. // In this case you can disable this plugin and shave off couple of seconds from your build.
  39. // Defaults to 'true'.
  40. updateMetafields: true
  41. }
  42. }