Gift Options Talons

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

GiftOptionsMutations : Object

GraphQL mutations for Gift Options

GiftOptionsQueries : Object

GraphQL query for Gift Options

GiftOptionsTalonProps : Object

Props data to use when rendering a gift options component.

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

Kind: global function

Param Type Description
props Object  
props.mutations GiftOptionsMutations GraphQL mutations for Gift Options
props.queries GiftOptionsQueries GraphQL queries for Gift Options

Example (Importing into your project)

import { useGiftOptions } from '@magento/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions';

GiftOptionsMutations : Object

GraphQL mutations for Gift Options

Kind: global typedef
See: giftOptions.gql.js for the query Venia uses.
Properties

Name Type Description
setGiftOptionsMutation GraphQLAST Mutation to use for setting the gift options for the cart

GiftOptionsQueries : Object

GraphQL query for Gift Options

Kind: global typedef
See: giftOptions.gql.js for the query Venia uses.
Properties

Name Type Description
getGiftOptionsQuery GraphQLAST Query to get gift options data

GiftOptionsTalonProps : Object

Props data to use when rendering a gift options component.

Kind: global typedef
Properties

Name Type Description
includeGiftReceipt boolean True if a gift receipt should be included. False otherwise.
includePrintedCard boolean True if a printed card should be included. False otherwise.
giftMessage String Message to include with a gift.
toggleIncludeGiftReceiptFlag function Toggles the value of the includeGiftReceipt value.
toggleIncludePrintedCardFlag function Toggles the value of the includePrintedCard value.
updateGiftMessage function Updates the gift message value.

For implementation details View Source.

Examples

useGiftOptions()

import React from 'react'

import useGiftOptions from '@magento/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions';
import MyGiftOptionsOperations from './myGiftOptions.gql';

const MyGiftOptions = props => {

    const { mutations, queries } = MyGiftOptionsOperations;

    const {
        includeGiftReceipt,
        includePrintedCard,
        giftMessage,
        toggleIncludeGiftReceiptFlag,
        toggleIncludePrintedCardFlag,
        updateGiftMessage
    } = useGiftOptions({ mutations, queries });

    return (
        // JSX that renders a Gift Options component using talon props
    )
}

export default MyGiftOptions