Skip to main content
Skip to main content

Gift Cards

Queries listed here are used to send requests to the Store Gift Card API Routes.

Customers can use gift cards during checkout to deduct the gift card's balance from the checkout total.

Related Guide: How to use gift cards in a storefront.

Queries

useGiftCard

This hook retrieves a Gift Card's details by its associated unique code.

Example

import React from "react"
import { useGiftCard } from "medusa-react"

type Props = {
giftCardCode: string
}

const GiftCard = ({ giftCardCode }: Props) => {
const { gift_card, isLoading, isError } = useGiftCard(
giftCardCode
)

return (
<div>
{isLoading && <span>Loading...</span>}
{gift_card && <span>{gift_card.value}</span>}
{isError && <span>Gift Card does not exist</span>}
</div>
)
}

export default GiftCard

Hook Parameters

idstringRequired
The gift card's ID.

Query Returned Data

gift_cardGiftCardRequired
Gift card details.
Was this section helpful?