@graphcommerce/magento-product-configurable 8.1.0-canary.5 → 8.1.0-canary.50

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.1.0-canary.50
4
+
5
+ ## 8.1.0-canary.49
6
+
7
+ ## 8.1.0-canary.48
8
+
9
+ ## 8.1.0-canary.47
10
+
11
+ ## 8.1.0-canary.46
12
+
13
+ ## 8.1.0-canary.45
14
+
15
+ ## 8.1.0-canary.44
16
+
17
+ ## 8.1.0-canary.43
18
+
19
+ ## 8.1.0-canary.42
20
+
21
+ ## 8.1.0-canary.41
22
+
23
+ ## 8.1.0-canary.40
24
+
25
+ ## 8.1.0-canary.39
26
+
27
+ ## 8.1.0-canary.38
28
+
29
+ ## 8.1.0-canary.37
30
+
31
+ ## 8.1.0-canary.36
32
+
33
+ ## 8.1.0-canary.35
34
+
35
+ ## 8.1.0-canary.34
36
+
37
+ ## 8.1.0-canary.33
38
+
39
+ ### Patch Changes
40
+
41
+ - [#2302](https://github.com/graphcommerce-org/graphcommerce/pull/2302) [`6b7f908`](https://github.com/graphcommerce-org/graphcommerce/commit/6b7f908b7a2561e9d7f6ec3eaf2a6aca8d77b72f) - Fixed tier prices not working for non-configurable products
42
+ ([@bramvanderholst](https://github.com/bramvanderholst))
43
+
44
+ ## 8.1.0-canary.32
45
+
46
+ ## 8.1.0-canary.31
47
+
48
+ ## 8.1.0-canary.30
49
+
50
+ ## 8.1.0-canary.29
51
+
52
+ ## 8.1.0-canary.28
53
+
54
+ ## 8.1.0-canary.27
55
+
56
+ ## 8.1.0-canary.26
57
+
58
+ ## 8.1.0-canary.25
59
+
60
+ ## 8.1.0-canary.24
61
+
62
+ ## 8.1.0-canary.23
63
+
64
+ ### Patch Changes
65
+
66
+ - [#2282](https://github.com/graphcommerce-org/graphcommerce/pull/2282) [`e048f61`](https://github.com/graphcommerce-org/graphcommerce/commit/e048f6165ae5a15be99fba0c3d3529c700477d3e) - Disable configurable product options that are unavailable for selection.
67
+ ([@carlocarels90](https://github.com/carlocarels90))
68
+
69
+ ## 8.1.0-canary.22
70
+
71
+ ## 8.1.0-canary.21
72
+
73
+ ## 8.1.0-canary.20
74
+
75
+ ## 8.1.0-canary.19
76
+
77
+ ## 8.1.0-canary.18
78
+
79
+ ## 8.1.0-canary.17
80
+
81
+ ## 8.1.0-canary.16
82
+
83
+ ## 8.1.0-canary.15
84
+
85
+ ## 8.1.0-canary.14
86
+
87
+ ## 8.1.0-canary.13
88
+
89
+ ## 8.1.0-canary.12
90
+
91
+ ## 8.1.0-canary.11
92
+
93
+ ## 8.1.0-canary.10
94
+
95
+ ## 8.1.0-canary.9
96
+
97
+ ## 8.1.0-canary.8
98
+
99
+ ### Patch Changes
100
+
101
+ - [#2247](https://github.com/graphcommerce-org/graphcommerce/pull/2247) [`444e446`](https://github.com/graphcommerce-org/graphcommerce/commit/444e446a218cc9da3defb940a6d5cce0229ff845) - Added clear upgrade instructions for linguiLocale
102
+ ([@paales](https://github.com/paales))
103
+
104
+ ## 8.1.0-canary.7
105
+
106
+ ## 8.1.0-canary.6
107
+
3
108
  ## 8.1.0-canary.5
4
109
 
5
110
  ## 8.0.6-canary.4
@@ -27,7 +27,6 @@ fragment ConfigurableProductForm on ConfigurableProduct {
27
27
  }
28
28
  product {
29
29
  ...ProductListItem
30
- ...ProductListItemSimple
31
30
  }
32
31
  }
33
32
  }
@@ -8,7 +8,7 @@ import {
8
8
  MessageSnackbar,
9
9
  IconSvg,
10
10
  } from '@graphcommerce/next-ui'
11
- import { Trans } from '@lingui/react'
11
+ import { Trans } from '@lingui/macro'
12
12
  import { Divider, Typography, Alert, Box, SxProps, Theme } from '@mui/material'
13
13
  import React from 'react'
14
14
  import { useConfigurableContext } from '../ConfigurableContext/ConfigurableContext'
@@ -140,7 +140,7 @@ export function ConfigurableProductAddToCart(props: ConfigurableProductAddToCart
140
140
  width: '100%',
141
141
  })}
142
142
  >
143
- <Trans id='Add to Cart' />
143
+ <Trans>Add to Cart</Trans>
144
144
  </Button>
145
145
  {additionalButtons}
146
146
  </Box>
@@ -172,15 +172,13 @@ export function ConfigurableProductAddToCart(props: ConfigurableProductAddToCart
172
172
  color='secondary'
173
173
  endIcon={<IconSvg src={iconChevronRight} />}
174
174
  >
175
- <Trans id='View shopping cart' />
175
+ <Trans>View shopping cart</Trans>
176
176
  </Button>
177
177
  }
178
178
  >
179
- <Trans
180
- id='<0>{name}</0> has been added to your shopping cart!'
181
- components={{ 0: <strong /> }}
182
- values={{ name }}
183
- />
179
+ <Trans>
180
+ <strong>{name}</strong> has been added to your shopping cart!
181
+ </Trans>
184
182
  </MessageSnackbar>
185
183
  </Box>
186
184
  )
@@ -1,14 +1,7 @@
1
- import { normalizeLocale } from '@graphcommerce/lingui-next'
2
1
  import { AddToCartItemSelector, useFormAddProductsToCart } from '@graphcommerce/magento-product'
3
- import {
4
- filterNonNullableKeys,
5
- ActionCardListProps,
6
- useStorefrontConfig,
7
- useLocale,
8
- } from '@graphcommerce/next-ui'
2
+ import { filterNonNullableKeys, ActionCardListProps, useLocale } from '@graphcommerce/next-ui'
9
3
  import { i18n } from '@lingui/core'
10
4
  import { Box, SxProps, Theme } from '@mui/material'
11
- import { useRouter } from 'next/router'
12
5
  import React, { useEffect, useMemo } from 'react'
13
6
  import { ConfigurableOptionsFragment } from '../../graphql/ConfigurableOptions.gql'
14
7
  import { useConfigurableOptionsSelection } from '../../hooks'
@@ -13,19 +13,4 @@ fragment ProductListItemConfigurable on ConfigurableProduct @inject(into: ["Prod
13
13
  }
14
14
  }
15
15
  }
16
- variants {
17
- attributes {
18
- value_index
19
- uid
20
- code
21
- }
22
- product {
23
- uid
24
- sku
25
- name
26
- small_image {
27
- ...ProductImage
28
- }
29
- }
30
- }
31
16
  }
@@ -2,16 +2,10 @@ import {
2
2
  ProductListItem,
3
3
  OverlayAreaKeys,
4
4
  ProductListItemProps,
5
- useProductListParamsContext,
6
- isFilterTypeEqual,
7
5
  } from '@graphcommerce/magento-product'
8
6
  import { SwatchList } from '../../SwatchList'
9
7
  import { ProductListItemConfigurableFragment } from './ProductListItemConfigurable.gql'
10
8
 
11
- export type ProductListItemConfigurableActionProps = ProductListItemConfigurableFragment & {
12
- variant?: NonNullable<ProductListItemConfigurableFragment['variants']>[0]
13
- }
14
-
15
9
  export type ProdustListItemConfigurableProps = ProductListItemConfigurableFragment &
16
10
  ProductListItemProps & {
17
11
  swatchLocations?: Partial<Record<OverlayAreaKeys, string[]>>
@@ -19,7 +13,6 @@ export type ProdustListItemConfigurableProps = ProductListItemConfigurableFragme
19
13
 
20
14
  export function ProductListItemConfigurable(props: ProdustListItemConfigurableProps) {
21
15
  const {
22
- variants,
23
16
  configurable_options,
24
17
  children,
25
18
  swatchLocations = { bottomLeft: [], bottomRight: [], topLeft: [], topRight: [] },
@@ -29,40 +22,10 @@ export function ProductListItemConfigurable(props: ProdustListItemConfigurablePr
29
22
  topRight,
30
23
  ...configurableProduct
31
24
  } = props
32
- const { params } = useProductListParamsContext()
33
-
34
- const options: [string, string[]][] =
35
- configurable_options
36
- ?.filter(
37
- (option) =>
38
- option?.attribute_code &&
39
- params.filters[option.attribute_code] &&
40
- isFilterTypeEqual(params.filters[option.attribute_code]),
41
- )
42
- .map((option) => {
43
- const filter = params.filters[option?.attribute_code ?? '']
44
- return [option?.attribute_code ?? '', (filter?.in as string[]) ?? []]
45
- }) ?? []
46
-
47
- const selected = {}
48
-
49
- options.forEach(([attr, values]) => {
50
- if (!selected[attr]) selected[attr] = values
51
- })
52
-
53
- const matchingVariants = variants?.filter(
54
- (variant) =>
55
- variant?.attributes?.filter(
56
- (attribute) =>
57
- selected[attribute?.code ?? ''] !== undefined &&
58
- selected[attribute?.code ?? ''].includes(String(attribute?.value_index)),
59
- ).length,
60
- )
61
25
 
62
26
  return (
63
27
  <ProductListItem
64
28
  {...configurableProduct}
65
- small_image={matchingVariants?.[0]?.product?.small_image ?? configurableProduct.small_image}
66
29
  topLeft={
67
30
  <>
68
31
  {topLeft}
@@ -1,4 +1,4 @@
1
- fragment ConfigurableOptions on ConfigurableProduct @injectable {
1
+ fragment ConfigurableOptions on ConfigurableProduct {
2
2
  __typename
3
3
  uid
4
4
  sku
@@ -1,4 +1,4 @@
1
- fragment ConfigurableOptionsSelection on ConfigurableProduct @injectable {
1
+ fragment ConfigurableOptionsSelection on ConfigurableProduct {
2
2
  configurable_product_options_selection(configurableOptionValueUids: $selectedOptions) {
3
3
  __typename
4
4
  configurable_options {
@@ -16,7 +16,7 @@ export function useConfigurableOptionsForSelection(variables: UseConfigurableOpt
16
16
 
17
17
  const selection = useQuery(GetConfigurableOptionsSelectionDocument, {
18
18
  variables: { urlKey: url_key ?? '', selectedOptions },
19
- skip: !url_key || !selectedOptions.length,
19
+ skip: !url_key,
20
20
  })
21
21
 
22
22
  const configured = selection.error
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product-configurable",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.1.0-canary.5",
5
+ "version": "8.1.0-canary.50",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,23 +12,23 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^8.1.0-canary.5",
16
- "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.5",
17
- "@graphcommerce/graphql": "^8.1.0-canary.5",
18
- "@graphcommerce/graphql-mesh": "^8.1.0-canary.5",
19
- "@graphcommerce/image": "^8.1.0-canary.5",
20
- "@graphcommerce/lingui-next": "8.1.0-canary.5",
21
- "@graphcommerce/magento-cart": "^8.1.0-canary.5",
22
- "@graphcommerce/magento-cart-items": "^8.1.0-canary.5",
23
- "@graphcommerce/magento-category": "^8.1.0-canary.5",
24
- "@graphcommerce/magento-customer": "^8.1.0-canary.5",
25
- "@graphcommerce/magento-product": "^8.1.0-canary.5",
26
- "@graphcommerce/magento-product-simple": "^8.1.0-canary.5",
27
- "@graphcommerce/magento-store": "^8.1.0-canary.5",
28
- "@graphcommerce/next-ui": "^8.1.0-canary.5",
29
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.5",
30
- "@graphcommerce/react-hook-form": "^8.1.0-canary.5",
31
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.5",
15
+ "@graphcommerce/ecommerce-ui": "^8.1.0-canary.50",
16
+ "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.50",
17
+ "@graphcommerce/graphql": "^8.1.0-canary.50",
18
+ "@graphcommerce/graphql-mesh": "^8.1.0-canary.50",
19
+ "@graphcommerce/image": "^8.1.0-canary.50",
20
+ "@graphcommerce/lingui-next": "8.1.0-canary.50",
21
+ "@graphcommerce/magento-cart": "^8.1.0-canary.50",
22
+ "@graphcommerce/magento-cart-items": "^8.1.0-canary.50",
23
+ "@graphcommerce/magento-category": "^8.1.0-canary.50",
24
+ "@graphcommerce/magento-customer": "^8.1.0-canary.50",
25
+ "@graphcommerce/magento-product": "^8.1.0-canary.50",
26
+ "@graphcommerce/magento-product-simple": "^8.1.0-canary.50",
27
+ "@graphcommerce/magento-store": "^8.1.0-canary.50",
28
+ "@graphcommerce/next-ui": "^8.1.0-canary.50",
29
+ "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.50",
30
+ "@graphcommerce/react-hook-form": "^8.1.0-canary.50",
31
+ "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.50",
32
32
  "@lingui/core": "^4.2.1",
33
33
  "@lingui/macro": "^4.2.1",
34
34
  "@lingui/react": "^4.2.1",
@@ -1,12 +1,14 @@
1
1
  import type { CartItemActionCardProps } from '@graphcommerce/magento-cart-items'
2
- import type { PluginProps } from '@graphcommerce/next-config'
2
+ import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
3
3
  import { isTypename } from '@graphcommerce/next-ui'
4
4
  import { ConfigurableCartItemOptions } from '../components'
5
5
 
6
- export const component = 'CartItemActionCard'
7
- export const exported = '@graphcommerce/magento-cart-items'
6
+ export const config: PluginConfig = {
7
+ type: 'component',
8
+ module: '@graphcommerce/magento-cart-items',
9
+ }
8
10
 
9
- export function ConfigurableCartItemActionCard(props: PluginProps<CartItemActionCardProps>) {
11
+ export function CartItemActionCard(props: PluginProps<CartItemActionCardProps>) {
10
12
  const { Prev, ...rest } = props
11
13
 
12
14
  if (!isTypename(rest.cartItem, ['ConfigurableCartItem'])) return <Prev {...rest} />
@@ -36,5 +38,3 @@ export function ConfigurableCartItemActionCard(props: PluginProps<CartItemAction
36
38
  />
37
39
  )
38
40
  }
39
-
40
- export const Plugin = ConfigurableCartItemActionCard
@@ -14,9 +14,10 @@ const ConfigurableProductPagePriceTiers = (
14
14
  const { Prev, product, index, ...rest } = props
15
15
  const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
16
16
 
17
- if (!variant) return null
17
+ if (!variant || product.__typename !== 'ConfigurableProduct')
18
+ return <Prev product={product} {...rest} />
18
19
 
19
- return <Prev product={variant} {...rest} />
20
+ return <Prev product={{ ...variant, options: product.options }} {...rest} />
20
21
  }
21
22
 
22
23
  export const Plugin = ConfigurableProductPagePriceTiers
@@ -27,17 +27,19 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
27
27
  client: ApolloClient<object>,
28
28
  query: Q,
29
29
  ): Q & Pick<AddProductsToCartFormProps, 'defaultValues'> {
30
- if (!import.meta.graphCommerce.configurableVariantForSimple) {
30
+ const simple = query?.products?.items?.find((p) => p?.url_key === urlKey)
31
+ const configurable = findByTypename(query?.products?.items, 'ConfigurableProduct')
32
+
33
+ if (
34
+ simple?.__typename === 'SimpleProduct' &&
35
+ !import.meta.graphCommerce.configurableVariantForSimple
36
+ ) {
31
37
  const product = query?.products?.items?.find((p) => p?.url_key === urlKey)
32
38
  return { ...query, products: { ...query?.products, items: [product] }, defaultValues: {} }
33
39
  }
34
40
 
35
- const simple = query?.products?.items?.find((p) => p?.url_key === urlKey)
36
- const configurable = findByTypename(query?.products?.items, 'ConfigurableProduct')
37
-
38
41
  // Check if the requested product actually is a simple product
39
- if (!simple || simple?.__typename !== 'SimpleProduct' || !configurable?.url_key)
40
- return { ...query, defaultValues: {} }
42
+ if (!configurable?.url_key) return { ...query, defaultValues: {} }
41
43
 
42
44
  // Find the requested simple product on the configurable variants and get the attributes.
43
45
  const attributes = configurable?.variants?.find(
@@ -45,8 +47,6 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
45
47
  )?.attributes
46
48
 
47
49
  const selectedOptions = (attributes ?? []).filter(nonNullable).map((a) => a.uid)
48
- if (!selectedOptions.length)
49
- return { ...query, products: { ...query?.products, items: [simple] }, defaultValues: {} }
50
50
 
51
51
  /**
52
52
  * We're using writeQuery to the Apollo Client cache, to to avoid a second request to the GraphQL
@@ -65,7 +65,6 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
65
65
  * })
66
66
  * ```
67
67
  */
68
-
69
68
  const optionsAvailableForSelection =
70
69
  configurable.configurable_product_options_selection?.options_available_for_selection?.filter(
71
70
  nonNullable,
@@ -104,8 +103,8 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
104
103
  option_value_uids,
105
104
  }),
106
105
  ),
107
- media_gallery: simple.media_gallery,
108
- variant: simple,
106
+ media_gallery: simple?.media_gallery ?? configurable.media_gallery,
107
+ variant: simple?.__typename === 'SimpleProduct' ? simple : null,
109
108
  },
110
109
  },
111
110
  ],