Edit in GitHubLog an issue

GiftOptions

Functions

useGiftOptions(props)GiftOptionsTalonProps

This talon contains the logic for a gift options component. It performs effects and returns a data object containing values for rendering the component.

This talon performs the following effects:

  • Fetch the gift options associated with the cart
  • Update the GiftOptionsTalonProps values with the data returned by the query

Typedefs

GiftOptionsTalonProps : Object

Props data to use when rendering a gift options component.

GiftOptionsOperations : Object

This is a type used by the useGiftOptions talon.

This talon contains the logic for a gift options component. It performs effects and returns a data object containing values for rendering the component.

This talon performs the following effects:

  • Fetch the gift options associated with the cart
  • Update the GiftOptionsTalonProps values with the data returned by the query

Returns: Parameters

NameType
propsObject
props.operationsGiftOptionsOperations

Example (Importing into your project)

Copied to your clipboard
import { useGiftOptions } from '@magento/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions';

Props data to use when rendering a gift options component.

Properties

NameTypeDescription
loadingBooleanQuery loading indicator.
errorsObjectErrors for GraphQl query and mutation.
savingOptionsArrayArray containing fields that are busy.
giftReceiptPropsObjectProps for the includeGiftReceipt checkbox element.
printedCardPropsObjectProps for the includePrintedCard checkbox element.
printedCardPriceObjectPrinted Card Price object.
giftMessageCheckboxPropsObjectProps for the includeGiftMessage checkbox element.
giftMessageResultObjectObject containing Gift Message data.
hasGiftMessageBooleanChecks if Gift Message data has all fields filled.
showGiftMessageResultBooleanShow or hide Gift Message result.
cardToPropsObjectProps for the cardTo text input element.
cardFromPropsObjectProps for the cardFrom text input element.
cardMessagePropsObjectProps for the cardMessage textarea element.
editGiftMessageButtonPropsObjectProps for the Edit Gift Message button.
cancelGiftMessageButtonPropsObjectProps for the Cancel Gift Message button.
saveGiftMessageButtonPropsObjectProps for the Update Gift Message button.
optionsFormPropsObjectProps for the form element.

This is a type used by the useGiftOptions talon.

Properties

NameTypeDescription
setGiftOptionsOnCartMutationGraphQLASTsets the gift options on cart.
getGiftOptionsQueryGraphQLASTfetch the gift options.

Source Code: pwa-studio/packages/peregrine/lib/talons/CartPage/PriceAdjustments/GiftOptions/useGiftOptions.js

Examples#

useGiftOptions()#

Copied to your clipboard
1import React from 'react'
2
3import useGiftOptions from '@magento/peregrine/lib/talons/CartPage/PriceAdjustments/GiftOptions/useGiftOptions';
4import MyGiftOptionsOperations from './myGiftOptions.gql';
5
6const MyGiftOptions = props => {
7
8 const { mutations, queries } = MyGiftOptionsOperations;
9
10 const {
11 includeGiftReceipt,
12 includePrintedCard,
13 giftMessage,
14 toggleIncludeGiftReceiptFlag,
15 toggleIncludePrintedCardFlag,
16 updateGiftMessage
17 } = useGiftOptions({ mutations, queries });
18
19 return (
20 // JSX that renders a Gift Options component using talon props
21 )
22}
23
24export default MyGiftOptions
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.