Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hey everyone
i tried to build a custom gift card app to shopify.
one of the functionality is that the customer can send the giftcard to other customer.
i create a webhook that listen to order creation an get the info.
if there is a line item property like "send to other" i want to prevent shopify automatic mail and send it from my api, to the email that the customer insert in "email to send" line item property.
any ideas how i can do that ? i know that gift card hero app do something like this.
thanks for the help !
Hi @omriWedev, this is a great question. I just want to confirm - you're not wanting an email to automatically be sent out when a gift card is created? If so, when you're using the Gift Card object in our GraphQL admin API to create the gift card, what you may first want to do is create the gift card without associating it with a customer ID. Then, once the Gift Card is created without a customer, reassign it to the customer you'd like to send the gift card out to using the GiftCardUpdate mutation.
This will have the effect of stopping the initial gift card email from being sent out upon creation, but then still having it be assigned to the right person. At the moment, it's the best workaround I am aware of, but let us know if you'd like us to forward some feedback on to our product team. I can understand how it might be easier to suppress the email with a field/value within the API call itself.
That said, our Gift Card API is limited to custom/private apps installed Shopify Plus stores only - at the moment, there's not a way to create gift cards for non-Plus stores using the API.
Hope this helps - let us know if we can clarify anything!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey, thanks for the response!
i`m thinking about something else to do:
when i get an order, in my api i checked if the order includes my gift card product,
if it includes, i get from it the "email to send" property and with this email i tried to search a customer in my shop and get the id of the customer,
then, i create a gift card with your api with customer_id that i get before.
this could be work ?
Hey @omriWedev - this could work! If I'm understanding correctly, you want to create a separate gift card product, filter for it with an API query and then pull the customer's email from that original order to create a "real" gift card via the Gift Card API?
In theory, you could use an orders query (GraphQL/REST) to pull the customer ID/email as well as to confirm they have that separate gift card product as a line item - then you'd use the Plus Gift Card API we were talking about a bit before to process a usable gift card.
Hope this helps - let us know if we can clarify anything further.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello @ShopifyDevSup , I want to jump on your solution.
```
{"data"=>{"giftCardUpdate"=>nil},
"errors"=>
[{"message"=>
"Access denied for giftCardUpdate field. Required access: `write_gift_cards` access scope. Also: The API client must be a private or custom app installed on a Shopify Plus or Shopify Plus Partner Sandbox store.",
"locations"=>[{"line"=>2, "column"=>3}],
"path"=>["giftCardUpdate"],
"extensions"=>
{"code"=>"ACCESS_DENIED",
"documentation"=>"https://shopify.dev/api/usage/access-scopes",
"requiredAccess"=>"`write_gift_cards` access scope. Also: The API client must be a private or custom app installed on a Shopify Plus or Shopify Plus Partner Sandbox store."}}],
"extensions"=>{"cost"=>{"requestedQueryCost"=>11, "actualQueryCost"=>10, "throttleStatus"=>{"maximumAvailable"=>1000.0, "currentlyAvailable"=>990, "restoreRate"=>50.0}}}}
```
I got this response when trying to update the GiftCard using the GraphQL's update mutation. I want to mention that I have activated write_gift_cards, read_gift_cards and even write_gift_card_adjustments and read_gift_card_adjustments enabled on my dev store.
There was no issue so far using the REST API, everything went ok.
What could be the problem? I can only use the mutation on a PLUS store? If I want to test it out, I can't on the development store?
Thank you.