Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Add email address for discount

Add email address for discount

availableuser
Visitor
1 0 0

I cannot find documentation that provides an example or work out how to add a customer to a discount code allow list.

 

Known:

  • discount code configured for specific customers
  • email address

Goal:

  • Get or create customer with the email address
  • Add customer to the discount code eligible customer list.

Thank you

Reply 1 (1)

lizk
Shopify Staff
246 58 79

Hi there 👋

Have you tried the discountCodeBasicUpdate mutation? 

//Mutaion
mutation discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {
  discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {
    codeDiscountNode {
      codeDiscount {
        ... on DiscountCodeBasic {
          title
          codes(first: 10) {
            nodes {
              code
            }
          }
          startsAt
          endsAt
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
          }
          customerGets {
            value {
              ... on DiscountPercentage {
                percentage
              }
            }
            items {
              ... on AllDiscountItems {
                allItems
              }
            }
          }
          appliesOncePerCustomer
        }
      }
    }
    userErrors {
      field
      code
      message
    }
  }
}
// Variables
{
  "id": "gid://shopify/DiscountCodeNode/1234",
  "basicCodeDiscount": {
    "customerSelection": {
      "customers": {
        "add": ["gid://Shopify/Customer/1234"]
      }
    }
    }
  }

 

To learn more visit the Shopify Help Center or the Community Blog.