๐๏ธPicket Shopify App - Merchant Documentation
Token gated commerce with a few simple clicks from your Shopify dashboard
Last updated
Token gated commerce with a few simple clicks from your Shopify dashboard
Last updated
Token gated products and discounts are common use cases of the Picket API. The Picket app on Shopify allows you to set up token gated discounts and token gated products from Shopify admin without the need for custom code.
Token Gated Discounts:
Enabling token gated discounts allows you to set discounts that can only be applied by users who hold the NFT or other token that you specify. You can do this on a product by product basis. You also can choose to require NFTs or tokens on any of the chains that Picket supports.
Token Gated Exclusive Products
Enabling token gated exclusive products allows you to set products as exclusives that can only be purchased by users who hold the NFT or other token that you specify. You can do this on a product by product basis. You also can choose to require NFTs or tokens on any of the chains that Picket supports.
The Shopify app is currently in beta. For private beta access, sign up here: https://forms.gle/uumfAnnzwFPtGoyeA
Before you begin, make sure that you have the Picket app for Shopify installed and open in Shopify admin.
Add your Picket API Key to Shopify Admin
Your Picket API key is located in your Picket dashboard and is listed under publishable key.
Copy your publishable key and paste it in the corresponding field in Shopify admin.
2. Select the tokens you would like to use for your token gate
For Ethereum and other EVM chains, this is done by putting the contract address of the tokens you'd like to use for your token gate into the contract address field.
If you don't know the contract address of the tokens you'd like to use for your token gate, you can find it for Ethereum and other EVM based chains by searching for your desired NFTs or other tokens here.
3. Select how many tokens you want to require users to have
For NFT token gates this is most commonly set to 1. However, this is up to you.
4. Set the discount rate you'd like to give to users who have the token you require
5. Select any products that you'd like the discount to apply to for users who hold your chosen token.
Follow the same steps above for setting token gated discounts. However, instead of selecting products at the end as discount products within the "Token Gate Configuration by Product Section" within Shopify Admin. Select products as exclusives with the checkboxes shown below:
Once you've configured your token gated exclusive and discounted products, you need to make it visible within your Shopify Shop theme. Like many other Shopify apps, this requires modifying the theme code, creating and rendering snippets, and adding data-picket
attributes to existing elements.
We'll walk you through each step in the process below, but if you get stuck or run into issue, don't hesitate to reach out to team@picketapi.com.
Checkout Shopify's documentation if you run into issues
To get started, we need to modify your Shop's theme code.
From your Shopify admin, go to Online Store > Themes.
Click Actions > Edit code.
The code editor shows a directory of theme files on the left, and a space to view and edit the files on the right.
Once you've opened up the Shop theme code editor, you'll see a directory called Snippets. Open the directory to reveal an Add a new snippet button.
We are going to use this button to create five snippets for different token gating functionality
picket.liquid
picket-product.liquid
picket-exclusive-badge.liquid
picket-discount-product.liquid
picket-cart-footer.liquid
Create each of these snippets and copy-paste their contents from below:
Well done! Now we can start modifying the theme's existing code to enable token gating.
The first step in enabling token gating is to allow users to verify token ownership. This is done via the picket-product
snippet.
Place this snippet on product pages above payment buttons like "Add to Cart", "Buy Now", etc.
In the Dawn theme, this snippet should be place in sections/main-product.liquid right above the submission form
Now users are able to verify token ownership! If you are looking at a token exclusive or discounted product, you should see a button like this
Next, we need to prevent users who don't hold the required tokens from adding token holder exclusive products to their cart.
To prevent users from purchasing exclusive products, we remove the payment buttons until the user has verified that they hold the necessary tokens. We do this by conditionally adding style="display: none;"
and data-picket="payment-buttons-container"
if the product is a token holder exclusive.
In the Dawn theme, this snippet should be place in sections/main-product.liquid at the outer most <div>
in the submission form
Depending on your shop theme, you may have to add this logic to multiple places. In the Dawn theme, you only need to add it one place. For token holder exclusive products, the payment buttons should be hidden, so you only see the verify token ownership button, like this
We now have token gated products! Next let's improve the user experience by showing which products are token gated and/or eligible for token holder discounts.
We want to indicate to users which products are exclusive to token holders. Similar to how we indicate which items are on sale, we are going to show a badge next to the price of products that are exclusive to token holders.
Add the following render
snippet to wherever your theme displays badges next to the product price.
In the Dawn theme, this snippet should be place at the bottom of snippets/price.liquid before the closing </div>
Once inserted, you'll see a badge next to the price of token holder exclusive products, like this
Next, we'll show the discounted price for products that are discounted for token holders.
There are a few steps to showing the discounted product price for token holders. First, we are going to find the <div>
s that contain the price displayed in our shop. Second, we will render
the discounted price for token holders. And finally, we'll add mark the regular price with a data attribute, so we can cross it out for users who hold the necessary tokens.
Find the container around the price displayed in your shop. In all relevant containers, add data-picket="price-container"
to the container element
In the Dawn theme, the price container <div>
lives in snippets/price.liquid with the class name "price__container"
Within the price container, we are going to render
the discounted price that token holders pay
In the Dawn theme, this snippet should be placed in snippets/price.liquid between the regular price and the sale price
Once this snippet is inserted, we should see the discounted price displayed below or next to the original price
Lastly, we are going to mark the regular price with a data-picket="price-regular-amount"
. This allows us to strikethrough the regular price once a user has verified token ownership.
In the Dawn theme, this snippet will be in snippets/price.liquid where the class name is "price-item--regular"
Amazing! Once a user verifies token ownership, they will automatically have the discount code applied at checkout to the relevant products and will see the new prices like this
Finally, we want to show users that have successfully verified ownership that they will have a discount applied at checkout to any eligible products.
Due to limitations of Shopify, we can't show the token holder discount applied when the user views the cart. Instead, we display a message to inform users that they will have discounts automatically applied at checkout.
To add the cart message, find the code that displays the checkout button on the cart page
In the Dawn theme, this snippet will be at the bottom of sections/main-cart-footer.liquid right after the cart tax notes
And that's it! For users that have verified token ownership, they'll see a message like this
And that's it! You are all done. You have enabled token gated products with an awesome user experience all controllable from an admin panel.
Need help setting up your token gated products and discounts? If you have any trouble with these instructions or just have a few questions, we're here to help. Email us at team@picketapi.com or find some time for a zoom call with a member of our engineering team for more hands on realtime help.