@graphcommerce/magento-cart 4.8.6 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,18 @@
1
1
  fragment CartItemCountChanged on Cart @injectable {
2
2
  __typename
3
3
  id
4
+ total_quantity
4
5
  items {
5
6
  __typename
6
7
  uid
7
8
  quantity
9
+ product {
10
+ uid
11
+ name
12
+ sku
13
+ thumbnail {
14
+ ...ProductImage
15
+ }
16
+ }
8
17
  }
9
18
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1675](https://github.com/graphcommerce-org/graphcommerce/pull/1675) [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6) Thanks [@paales](https://github.com/paales)! - Added crosssel functionality
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1655](https://github.com/graphcommerce-org/graphcommerce/pull/1655) [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5) Thanks [@FrankHarland](https://github.com/FrankHarland)! - Added Google Analytics support.
12
+
13
+ - Updated dependencies [[`9e630670f`](https://github.com/graphcommerce-org/graphcommerce/commit/9e630670ff6c952ab7b938d890b5509804985cf3), [`cf3518499`](https://github.com/graphcommerce-org/graphcommerce/commit/cf351849999ad6fe73ce2bb258098a7dd301d517), [`81f31d1e5`](https://github.com/graphcommerce-org/graphcommerce/commit/81f31d1e54397368088a4289aaddd29facfceeef), [`2e9fa5984`](https://github.com/graphcommerce-org/graphcommerce/commit/2e9fa5984a07ff14fc1b3a4f62189a26e8e3ecdd), [`adf13069a`](https://github.com/graphcommerce-org/graphcommerce/commit/adf13069af6460c960276b402237371c12fc6dec), [`a8905d263`](https://github.com/graphcommerce-org/graphcommerce/commit/a8905d263273cb9322583d5759a5fdc66eceb8e4), [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6), [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd), [`6c2e27b1b`](https://github.com/graphcommerce-org/graphcommerce/commit/6c2e27b1be4aaa888e65a2bd69eaeb467a54a023), [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5)]:
14
+ - @graphcommerce/next-ui@4.28.1
15
+ - @graphcommerce/graphql@3.5.0
16
+ - @graphcommerce/framer-scroller@2.1.41
17
+ - @graphcommerce/framer-utils@3.2.1
18
+ - @graphcommerce/magento-customer@4.12.0
19
+ - @graphcommerce/ecommerce-ui@1.5.4
20
+ - @graphcommerce/magento-store@4.3.2
21
+ - @graphcommerce/magento-graphql@3.1.9
22
+ - @graphcommerce/framer-next-pages@3.3.2
23
+ - @graphcommerce/image@3.1.10
24
+
25
+ ## 4.8.7
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`1f2e14ba8`](https://github.com/graphcommerce-org/graphcommerce/commit/1f2e14ba8b674b87257a123e8cb215157890eb22), [`fc32b9ab3`](https://github.com/graphcommerce-org/graphcommerce/commit/fc32b9ab3818eb99c546a89e7f42045a6fbfba81)]:
30
+ - @graphcommerce/react-hook-form@3.3.5
31
+ - @graphcommerce/ecommerce-ui@1.5.3
32
+ - @graphcommerce/magento-customer@4.11.7
33
+
3
34
  ## 4.8.6
4
35
 
5
36
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ query CartAdded($cartId: String!) {
2
+ cart(cart_id: $cartId) {
3
+ ...CartItemCountChanged
4
+ }
5
+ }
@@ -0,0 +1,15 @@
1
+ query Crosssells(
2
+ $pageSize: Int = 8
3
+ $currentPage: Int = 1
4
+ $filters: ProductAttributeFilterInput = {}
5
+ ) {
6
+ products(pageSize: $pageSize, currentPage: $currentPage, filter: $filters) {
7
+ items {
8
+ __typename
9
+ uid
10
+ crosssell_products {
11
+ ...ProductListItem
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from './CartAdded.gql'
2
+ export * from './Crosssells.gql'
@@ -1,4 +1,4 @@
1
- fragment CartStartCheckout on Cart @inject(into: ["CartItemCountChanged"]) {
1
+ fragment CartStartCheckout on Cart @injectable {
2
2
  prices {
3
3
  grand_total {
4
4
  ...Money
@@ -21,7 +21,7 @@ const parts = [
21
21
  const { classes } = extendableComponent(name, parts)
22
22
 
23
23
  export function CartStartCheckout(props: CartStartCheckoutProps) {
24
- const { prices, children, sx = [], buttonProps } = props
24
+ const { prices, children, buttonProps, sx = [] } = props
25
25
 
26
26
  const hasTotals = (prices?.grand_total?.value ?? 0) > 0
27
27
  return (
@@ -37,6 +37,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
37
37
  >
38
38
  <PageLink href='/checkout' passHref>
39
39
  <Button
40
+ href='/checkout'
40
41
  id='cart-start-checkout'
41
42
  variant='pill'
42
43
  color='secondary'
@@ -1,6 +1,8 @@
1
1
  fragment CartSummary on Cart {
2
2
  email
3
3
 
4
+ is_virtual
5
+
4
6
  shipping_addresses {
5
7
  selected_shipping_method {
6
8
  carrier_code
@@ -29,7 +29,7 @@ export function CartSummary(props: CartSummaryProps) {
29
29
 
30
30
  if (!data?.cart) return null
31
31
 
32
- const { email, shipping_addresses, billing_address } = data.cart
32
+ const { email, shipping_addresses, billing_address, is_virtual } = data.cart
33
33
 
34
34
  return (
35
35
  <Box
@@ -93,61 +93,61 @@ export function CartSummary(props: CartSummaryProps) {
93
93
  />
94
94
  <Typography variant='body1'>{email || ''}</Typography>
95
95
  </Box>
96
+ {!is_virtual && (
97
+ <Box>
98
+ <SectionContainer
99
+ variantLeft='h5'
100
+ labelLeft={<Trans id='Shipping method' />}
101
+ sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
102
+ />
103
+ <Typography variant='body1'>
104
+ {shipping_addresses?.[0]?.selected_shipping_method?.carrier_title}
105
+ {shipping_addresses?.[0]?.selected_shipping_method?.method_title}
106
+ </Typography>
107
+ </Box>
108
+ )}
109
+ {!is_virtual && shipping_addresses && (
110
+ <Box>
111
+ <SectionContainer
112
+ variantLeft='h5'
113
+ labelLeft={<Trans id='Shipping address' />}
114
+ sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
115
+ labelRight={
116
+ editable ? (
117
+ <PageLink href={historyHref} passHref>
118
+ <Link
119
+ color='secondary'
120
+ variant='body2'
121
+ onClick={historyOnClick}
122
+ underline='hover'
123
+ >
124
+ <Trans id='Edit' />
125
+ </Link>
126
+ </PageLink>
127
+ ) : undefined
128
+ }
129
+ />
130
+ <CartAddressMultiLine {...shipping_addresses[0]} />
131
+ </Box>
132
+ )}
96
133
  <Box>
97
134
  <SectionContainer
98
135
  variantLeft='h5'
99
- labelLeft={<Trans id='Shipping method' />}
136
+ labelLeft={<Trans id='Billing address' />}
100
137
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
101
- />
102
- <Typography variant='body1'>
103
- {shipping_addresses?.[0]?.selected_shipping_method?.carrier_title}
104
- {shipping_addresses?.[0]?.selected_shipping_method?.method_title}
105
- </Typography>
138
+ labelRight={
139
+ editable ? (
140
+ <PageLink href='/checkout/edit/billing-address' passHref>
141
+ <Link color='secondary' variant='body2' underline='hover'>
142
+ <Trans id='Edit' />
143
+ </Link>
144
+ </PageLink>
145
+ ) : undefined
146
+ }
147
+ >
148
+ <CartAddressMultiLine {...billing_address} />
149
+ </SectionContainer>
106
150
  </Box>
107
- {shipping_addresses && (
108
- <>
109
- <Box>
110
- <SectionContainer
111
- variantLeft='h5'
112
- labelLeft={<Trans id='Shipping address' />}
113
- sx={{ '& .SectionHeader': { marginTop: 0, paddingBottom: '8px' } }}
114
- labelRight={
115
- editable ? (
116
- <PageLink href={historyHref} passHref>
117
- <Link
118
- color='secondary'
119
- variant='body2'
120
- onClick={historyOnClick}
121
- underline='hover'
122
- >
123
- <Trans id='Edit' />
124
- </Link>
125
- </PageLink>
126
- ) : undefined
127
- }
128
- />
129
- <CartAddressMultiLine {...shipping_addresses[0]} />
130
- </Box>
131
- <Box>
132
- <SectionContainer
133
- variantLeft='h5'
134
- labelLeft={<Trans id='Billing address' />}
135
- sx={{ '& .SectionHeader': { marginTop: 0, paddingBottom: '8px' } }}
136
- labelRight={
137
- editable ? (
138
- <PageLink href='/checkout/edit/billing-address' passHref>
139
- <Link color='secondary' variant='body2' underline='hover'>
140
- <Trans id='Edit' />
141
- </Link>
142
- </PageLink>
143
- ) : undefined
144
- }
145
- >
146
- <CartAddressMultiLine {...billing_address} />
147
- </SectionContainer>
148
- </Box>
149
- </>
150
- )}
151
151
  </Box>
152
152
  {children}
153
153
  </Box>
@@ -1,4 +1,5 @@
1
1
  export * from './ApolloCartError'
2
+ export * from './CartAdded'
2
3
  export * from './CartAddressMultiLine/CartAddressMultiLine'
3
4
  export * from './CartAddressSingleLine/CartAddressSingleLine'
4
5
  export * from './CartAgreementsForm/CartAgreements.gql'
@@ -7,6 +8,7 @@ export * from './CartFab/CartFab'
7
8
  export * from './CartItemSummary/CartItemSummary'
8
9
  export * from './CartStartCheckout/CartStartCheckout'
9
10
  export * from './CartSummary/CartSummary'
11
+ export * from './CartSummary/CartSummary.gql'
10
12
  export * from './CartTotals/CartTotals'
11
13
  export * from './EmptyCart/EmptyCart'
12
14
  export * from './InlineAccount/InlineAccount'
@@ -12,7 +12,12 @@ type UseCurrentCartIdOptions<Q, V> = QueryHookOptions<
12
12
  export function useCurrentCartId<Q, V>(options: UseCurrentCartIdOptions<Q, V> = {}) {
13
13
  const { hydration = false, ...queryOptions } = options
14
14
  const [hydrating, setHydrating] = useState(!hydration)
15
- useIsomorphicLayoutEffect(() => startTransition(() => setHydrating(false)), [])
15
+
16
+ useIsomorphicLayoutEffect(() => {
17
+ if (!hydrating) return
18
+ startTransition(() => setHydrating(false))
19
+ }, [hydrating])
20
+
16
21
  const skip = options.skip !== undefined ? options.skip : hydrating
17
22
 
18
23
  const { data, ...queryResults } = useQuery(CurrentCartIdDocument, { ...queryOptions, skip })
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.8.6",
5
+ "version": "4.9.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,17 +18,17 @@
18
18
  "@playwright/test": "^1.21.1"
19
19
  },
20
20
  "dependencies": {
21
- "@graphcommerce/ecommerce-ui": "1.5.2",
22
- "@graphcommerce/framer-utils": "3.2.0",
23
- "@graphcommerce/framer-next-pages": "3.3.1",
24
- "@graphcommerce/framer-scroller": "2.1.40",
25
- "@graphcommerce/graphql": "3.4.8",
26
- "@graphcommerce/image": "3.1.9",
27
- "@graphcommerce/magento-customer": "4.11.6",
28
- "@graphcommerce/magento-graphql": "3.1.8",
29
- "@graphcommerce/magento-store": "4.3.1",
30
- "@graphcommerce/next-ui": "4.28.0",
31
- "@graphcommerce/react-hook-form": "3.3.4"
21
+ "@graphcommerce/ecommerce-ui": "1.5.4",
22
+ "@graphcommerce/framer-utils": "3.2.1",
23
+ "@graphcommerce/framer-next-pages": "3.3.2",
24
+ "@graphcommerce/framer-scroller": "2.1.41",
25
+ "@graphcommerce/graphql": "3.5.0",
26
+ "@graphcommerce/image": "3.1.10",
27
+ "@graphcommerce/magento-customer": "4.12.0",
28
+ "@graphcommerce/magento-graphql": "3.1.9",
29
+ "@graphcommerce/magento-store": "4.3.2",
30
+ "@graphcommerce/next-ui": "4.28.1",
31
+ "@graphcommerce/react-hook-form": "3.3.5"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@lingui/react": "^3.13.2",