A space to discuss online store customization, theme development, and Liquid templating.
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 ?
Solved! Go to the solution
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.
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'
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.
Thanks, it makes sense now
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'