@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
349 lines (338 loc) • 6.52 kB
JavaScript
const CartLineAdd = (cartFragment) => (
/* GraphQL */
`
mutation CartLineAdd(
$cartId: ID!
$lines: [CartLineInput!]!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartLinesAdd(cartId: $cartId, lines: $lines) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartCreate = (cartFragment) => (
/* GraphQL */
`
mutation CartCreate(
$input: CartInput!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartCreate(input: $input) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartLineRemove = (cartFragment) => (
/* GraphQL */
`
mutation CartLineRemove(
$cartId: ID!
$lines: [ID!]!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartLinesRemove(cartId: $cartId, lineIds: $lines) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartLineUpdate = (cartFragment) => (
/* GraphQL */
`
mutation CartLineUpdate(
$cartId: ID!
$lines: [CartLineUpdateInput!]!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartLinesUpdate(cartId: $cartId, lines: $lines) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartNoteUpdate = (cartFragment) => (
/* GraphQL */
`
mutation CartNoteUpdate(
$cartId: ID!
$note: String!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartNoteUpdate(cartId: $cartId, note: $note) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartBuyerIdentityUpdate = (cartFragment) => (
/* GraphQL */
`
mutation CartBuyerIdentityUpdate(
$cartId: ID!
$buyerIdentity: CartBuyerIdentityInput!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartAttributesUpdate = (cartFragment) => (
/* GraphQL */
`
mutation CartAttributesUpdate(
$attributes: [AttributeInput!]!
$cartId: ID!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartDiscountCodesUpdate = (cartFragment) => (
/* GraphQL */
`
mutation CartDiscountCodesUpdate(
$cartId: ID!
$discountCodes: [String!]!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
cart {
...CartFragment
}
}
}
${cartFragment}
`
);
const CartQuery = (cartFragment) => (
/* GraphQL */
`
query CartQuery(
$id: ID!
$numCartLines: Int = 250
$country: CountryCode = ZZ
$language: LanguageCode
$visitorConsent: VisitorConsent
)
@inContext(
country: $country
language: $language
visitorConsent: $visitorConsent
) {
cart(id: $id) {
...CartFragment
}
}
${cartFragment}
`
);
const defaultCartFragment = (
/* GraphQL */
`
fragment CartFragment on Cart {
id
checkoutUrl
totalQuantity
buyerIdentity {
countryCode
customer {
id
email
firstName
lastName
displayName
}
email
phone
}
lines(first: $numCartLines) {
edges {
node {
id
quantity
attributes {
key
value
}
cost {
totalAmount {
amount
currencyCode
}
compareAtAmountPerQuantity {
amount
currencyCode
}
}
merchandise {
... on ProductVariant {
id
availableForSale
compareAtPrice {
...MoneyFragment
}
price {
...MoneyFragment
}
requiresShipping
title
image {
...ImageFragment
}
product {
handle
title
id
}
selectedOptions {
name
value
}
}
}
}
}
}
cost {
subtotalAmount {
...MoneyFragment
}
totalAmount {
...MoneyFragment
}
totalDutyAmount {
...MoneyFragment
}
totalTaxAmount {
...MoneyFragment
}
}
note
attributes {
key
value
}
discountCodes {
code
applicable
}
}
fragment MoneyFragment on MoneyV2 {
currencyCode
amount
}
fragment ImageFragment on Image {
id
url
altText
width
height
}
`
);
export {
CartAttributesUpdate,
CartBuyerIdentityUpdate,
CartCreate,
CartDiscountCodesUpdate,
CartLineAdd,
CartLineRemove,
CartLineUpdate,
CartNoteUpdate,
CartQuery,
defaultCartFragment
};
//# sourceMappingURL=cart-queries.mjs.map