Shopify
Last updated
Last updated
We’re opening up a world where fans feel a meaningful connection to their brands, and where NFTs just increasingly become part of how we buy and sell online. An example is Shopify, which has made it possible for eligible sellers to sell NFTs (non-fungible tokens) via its platform, which opens up a whole new world for e-commerce merchants. By making it possible for merchants to sell NFTs directly through their Shopify storefronts, we're seeing a lot of opportunities to blend Shopify into our app.
A place where LTL/GVO/DDA official merchandise lives. All items are tokenized, meaning that you can buy an NFT that gives you the right to claim an item. Since all items are tokenized, they are limited and require on-chain transactions. LTL will add a non-fungible token (NFT) component to its monthly GVO & DDA Collection. On the first Friday of every month, LTL might make a very limited edition item available for purchase in selected markets for 33 hours. There are often only 300 editions available on a first-come, first-served basis. And the piece is delivered in a custom package straight to the purchaser’s door. The purchase will be unlocked by the LTL Founders Pass NFT.
Navigate to the Apps tab in your store and hit the "Manage private apps" link at the bottom. Accept the terms and conditions, name your private app "Next.js Connection" and enter your email address. Then scroll down and check "Allow this app to access your storefront data using using the Storefront API".
Create .env.local file in the root folder of your Next.js app and add these variables:
Scroll to the bottom, hit "Select all" scopes for Storefront API access, and install the Shopify GraphiQL app that will help you to test your queries before you use them in your app. (Before proceeding with this step, add some sample products to your store and make sure they are available for the GraphiQL App sales channel). Now open the GraphiQL app, choose the Storefront API schema and paste this into the query field:
Inside the Next.js app, create a lib folder in the root directory and create a shopify.js file inside of it.
What we are doing above:
Creating a function called ShopifyData that will accept a query.
ShopifyData it will make a POST request to the Shopify Storefront GraphQL API using the set headers and return the json response.
ShopifyData function will return the data to the getAllProducts function which will set it equal to the allProducts variable.
To display products on the homepage, we add inside our index.js file:
Create a ProductCard.js component in a new folder called components:
What's happening above:
We are using the getStaticProps function provided to us by Next.js to prefetch all the products from the getAllProducts function from our shopify.js file.
Passing the products as a prop to our homepage function.
Creating a ProductCard.js to display a single product card.
Mapping over the products and displaying the ProductCard.js for each one.
Next Steps:
Dynamic product pages using the getStaticPaths Next.js function.
Create add-to-cart functionality using React Context for cart state management.
Deploy to Vercel.