detail page port

This commit is contained in:
nicwands
2026-05-29 11:22:56 -04:00
parent b85d28c142
commit e22d75c50a
65 changed files with 7006 additions and 4044 deletions

133
libs/shopify/cart.js Normal file
View File

@@ -0,0 +1,133 @@
import { gql } from 'graphql-request'
import { IMAGE_FRAGMENT, PRICE_FRAGMENT } from './fragments'
export const CART_FRAGMENT = gql`
fragment CartFields on Cart {
id
checkoutUrl
cost {
subtotalAmount {
...PriceFields
}
}
totalQuantity
discountCodes {
code
applicable
}
buyerIdentity {
email
customer {
id
}
}
lines(first: 100) {
edges {
node {
id
cost {
totalAmount {
...PriceFields
}
}
quantity
merchandise {
... on ProductVariant {
id
product {
handle
title
}
image {
...ImageFields
}
selectedOptions {
name
value
}
}
}
}
}
}
}
`
export const CREATE_CART = gql`
${PRICE_FRAGMENT}
${IMAGE_FRAGMENT}
${CART_FRAGMENT}
mutation createCart($input: CartInput) {
cartCreate(input: $input) {
cart {
...CartFields
}
}
}
`
export const ADD_TO_CART = gql`
${PRICE_FRAGMENT}
${IMAGE_FRAGMENT}
${CART_FRAGMENT}
mutation addToCart($cartId: ID!, $lines: [CartLineInput!]!) {
cartLinesAdd(cartId: $cartId, lines: $lines) {
cart {
...CartFields
}
}
}
`
export const REMOVE_FROM_CART = gql`
${PRICE_FRAGMENT}
${IMAGE_FRAGMENT}
${CART_FRAGMENT}
mutation removeFromCart($cartId: ID!, $lineIds: [ID!]!) {
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
cart {
...CartFields
}
}
}
`
export const UPDATE_DISCOUNT_CODES = gql`
${PRICE_FRAGMENT}
${IMAGE_FRAGMENT}
${CART_FRAGMENT}
mutation updateDiscountCodes($cartId: ID!, $discountCodes: [String!]!) {
cartDiscountCodesUpdate(
cartId: $cartId
discountCodes: $discountCodes
) {
cart {
...CartFields
}
}
}
`
export const UPDATE_BUYER_ID = gql`
${PRICE_FRAGMENT}
${IMAGE_FRAGMENT}
${CART_FRAGMENT}
mutation updateBuyerId(
$cartId: ID!
$buyerIdentity: CartBuyerIdentityInput!
) {
cartBuyerIdentityUpdate(
cartId: $cartId
buyerIdentity: $buyerIdentity
) {
cart {
...CartFields
}
}
}
`