Listing all gift cards of the customer

Solved

Listing all gift cards of the customer

seymur_crsp
Shopify Partner
67 4 10

I would like to list all gift cards belonging to the currently logged user in the account page. Is that possible ? Seems like there's a gift_card.liquid template which has access to only one gift card. How can I get the array of all gift cards of the customer ?

Accepted Solutions (2)

Jason
Shopify Partner
11201 226 2310

This is an accepted solution.

Gift Cards don't belong to a customer upon purchase. A customer buys them and that data is stored in the object. eg:

 

{
  "api_client_id": 431223487,
  "balance": 80.17,
  "code": "1234 4567 8901 2ABC",
  "created_at": "2008-12-31T19:00:00-05:00",
  "currency": "CAD",
  "customer_id": {
    "customer_id": 368407052327
  },
  "disabled_at": "2009-01-31T19:00:00-05:00",
  "expires_on": "2020-01-31",
  "id": 989034056,
  "initial_value": 100,
  "last_characters": "2ABC",
  "line_item_id": 241253183,
  "note": "A note",
  "order_id": 241253183,
  "template_suffix": "birthday",
  "user_id": 241253183,
  "updated_at": "2009-01-31T19:00:00-05:00"
}

 

You can read that customer ID via the API. However since a gift card can be given to someone else it's very likely the purchaser (the customer ID shown) is no longer the owner.

 

How would showing a list of cards purchased help? And do note that the card code isn't reveal once created - only a partial code will be available.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

View solution in original post

eliasdiek
Shopify Partner
7 2 4

This is an accepted solution.

Hey @seymur_crsp,

Giftcard search endpoint supports search by email and it returns gift card array that belongs to the customer.

Please see below:

const API_URL = ‘…myshopify.com/admin/api/2022-07/gift_cards/search.json?query=email:customer@example.com' 

Elias Diek

View solution in original post

Replies 3 (3)

Jason
Shopify Partner
11201 226 2310

This is an accepted solution.

Gift Cards don't belong to a customer upon purchase. A customer buys them and that data is stored in the object. eg:

 

{
  "api_client_id": 431223487,
  "balance": 80.17,
  "code": "1234 4567 8901 2ABC",
  "created_at": "2008-12-31T19:00:00-05:00",
  "currency": "CAD",
  "customer_id": {
    "customer_id": 368407052327
  },
  "disabled_at": "2009-01-31T19:00:00-05:00",
  "expires_on": "2020-01-31",
  "id": 989034056,
  "initial_value": 100,
  "last_characters": "2ABC",
  "line_item_id": 241253183,
  "note": "A note",
  "order_id": 241253183,
  "template_suffix": "birthday",
  "user_id": 241253183,
  "updated_at": "2009-01-31T19:00:00-05:00"
}

 

You can read that customer ID via the API. However since a gift card can be given to someone else it's very likely the purchaser (the customer ID shown) is no longer the owner.

 

How would showing a list of cards purchased help? And do note that the card code isn't reveal once created - only a partial code will be available.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
seymur_crsp
Shopify Partner
67 4 10

Thanks, it makes sense now

eliasdiek
Shopify Partner
7 2 4

This is an accepted solution.

Hey @seymur_crsp,

Giftcard search endpoint supports search by email and it returns gift card array that belongs to the customer.

Please see below:

const API_URL = ‘…myshopify.com/admin/api/2022-07/gift_cards/search.json?query=email:customer@example.com' 

Elias Diek