How to add a display name of a discount code

Hello !

I would like to know if it’s possible to add a “displayname” if i can call it like that, to a discount code.
Let me explain what i’m trying to do :
In each order, i add a small scratching card with a unique discount code or gift card.

So, i have A LOT of discount codes, and i would like to know if it is possible to edit what’s displayed here :

So i could easily differentiate discounts created for the scratch game and other discounts.

I doesn’t want to change the discount codes themselves as the cards are already printed and shipped to customers.

Thanks,
Greg

Hi Greg,

Technically, if you create/update a discount code via the Shopify API, it can have both and “code” and a “title.”

https://shopify.dev/docs/api/admin-graphql/2024-10/input-objects/DiscountCodeBasicInput

The “code” is what the customers enter. The “title” shows in the Shopify admin and to customers (at least, according to the docs).

However, I’ve seen that, at least with Shopify Functions-based discounts, the “title” is not shown to customers. Maybe Shopify’s built-in discounts follow the same rules.

It could be worth trying to set a “title” for each discount via the discountCodeBasicUPdate API. You could use Shopify’s GraphiQL app for this.

Hope this helps,

Tobe

Hello there Greg @greg_brtn You can solve this issue by using meta field

Step 1: Create a discount code for specific products eg: 100%OFF

Step 2: Create a product metafield to fill in discount code

Step 3: Add in the discount code 100%OFF to metafield of product you want

Step 4: Add a block to product page and use dynamic field to call metafield

Note: You can replace the “100% OFF” with something else you want as the display name. Let me know if it works for you.

Hello,

Thanks for your answer !
I successfully updated a discount code using GraphiQL :

Here’s the request I used if anyone is interested in doing the same thing :

mutation discountCodeBasicUpdate{
  discountCodeBasicUpdate(
    id: "gid://shopify/DiscountCodeNode/THE_ID_OF_YOUR_DISCOUNT"
    basicCodeDiscount: {
      title: "THE_TITLE_YOU_WANT_TO_GIVE"
    }
  ) {
    codeDiscountNode{
      id
      codeDiscount{
        ... on DiscountCodeBasic {
          title
          codes(first: 1) {
            nodes {
              code
            }
          }
        }
      }
    }
  }
}

Regards,
Greg

Hello,

Unfortunately, as i have 100+ unique discount codes, limited to 1 use and for all products, this solution seems way too complex to implement.

Thank you anyway for your answer !