Discount Codes By A Customer ID Or Email using Graphql

Discount Codes By A Customer ID Or Email using Graphql


0

I am trying to select discount codes assigned to a logged-in user using admin graphql API. I am able to select all discount codes but I am not able to filter them by customer ID or customer email address. Here is my GQL. Can you guide me on how can limit the results to specified customers?

{
  priceRules(first: 10, reverse: true) {
    nodes {
      customerSelection {
        customers(first: 10) {
          edges {
            node {
              id
              email
            }
          }
        }
      }
      title
    }
  }
}

1 Answer
1


0

According to the docs at here , the customers field supports a argument called query which supports the filtering the follows :

  • accepts_marketing
  • country
  • customer_date
  • email
  • last_abandoned_order_date
  • order_date
  • orders_count
  • phone
  • state
  • tag
  • tag_not
  • total_spent
  • updated_at

And based on the doc of the query syntax , think that the customer email can be filtered by :

{
  priceRules(first: 10, reverse: true) {
    nodes {
      customerSelection {
        customers(first: 10,query :"email:[email protected]") {
          edges {
            node {
              id
              email
            }
          }
        }
      }
      title
    }
  }
}




Leave a Reply

Your email address will not be published. Required fields are marked *