๐Ÿ›๏ธPicket Shopify App - Merchant Documentation

Token gated commerce with a few simple clicks from your Shopify dashboard

Overview

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.

Installation

The Shopify app is currently in beta. For private beta access, sign up here: https://forms.gle/uumfAnnzwFPtGoyeA

Setting Token Gated Discounts (Ethereum and other EVM Chains)

Before you begin, make sure that you have the Picket app for Shopify installed and open in Shopify admin.

  1. 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.

Setting Token Gated Exclusive Products

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:

Shop Theme Installation

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.

1. Modify Theme Code ๐Ÿ‘ฉโ€๐Ÿ’ป

Checkout Shopify's documentation if you run into issues

To get started, we need to modify your Shop's theme code.

  1. From your Shopify admin, go to Online Store > Themes.

  2. 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.

2. Create Picket Snippets โœ‚

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:

picket.liquid
{% comment %}
  This snippet must be named: picket.liquid
{% endcomment %}

<script src="https://cdn.jsdelivr.net/npm/@picketapi/picket-js/dist/global.js"></script>

<style>
:root {
  --picket-purple: #5469d4;
}
  .picketPurpleColor {
    color: var(--picket-purple);
  }
  
  .picketButton {
    background-color: var(--picket-purple);
    color: #fff;

    border: none;
    
    font-family: Assistant, sans-serif;
    
    width: 100%;
    margin: 1rem 0;
    padding-top: 15px;
    padding-bottom: 15px;
    text-align: center;
  }

  .cartMessage {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  @media screen and (min-width: 750px) {
    .cartMessage {
      text-align: right;
      justify-content: flex-end;
      align-items: ce;
    }
  }
</style>

<script src="https://picket-shopify.fly.dev/store.js" ></script>

Well done! Now we can start modifying the theme's existing code to enable token gating.

3. Token Gate Products ๐ŸŒ‰

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

{% comment %}
  This snippet display the "Verify Token Ownership" button
  and a success message for token holders. 
  
  Place it above the payment buttons, like "Add to Cart", "Buy Now", etc
{% endcomment %}

{% render 'picket-product', product: product %}

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

{% comment %}
  This is an example of conditionally adding the field to a div element
{% endcomment %}

<div 
  {%- if product.tags contains "picket_exclusive"  -%}
    data-picket="payment-buttons-container"
    style="display: none;"
  {%- endif -%}
>

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.

4. Display Token Holder Exclusive Badge ๐Ÿชช

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>

{% comment %}
  Remember to pass the product object as an argument to the render function
{% endcomment %}

{% render 'picket-exclusive-badge', product: product %}

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.

5. Display Token Holder Discount Price ๐Ÿท

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"

{% comment %}
  Add data-picket="price-container" to the existing element
{% endcomment %}

<div data-picket="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

{% comment %}
  Remember to pass the product object and the numeric price 
  as arguments to the render function
{% endcomment %}

{% render 'picket-discount-price', product: product, price: 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"

{% comment %}
  An example of how to modify the regular price element
{% endcomment %}

<span data-picket="price-regular-amount">
  {{ money_price }}
</span>

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

6. Show Token Discount Message in Cart ๐Ÿ’Œ

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

{% render 'picket-cart-footer' %}

And that's it! For users that have verified token ownership, they'll see a message like this

7. Done ๐ŸŽ‰

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.

Support

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.

Last updated