@graphcommerce/magento-product-configurable 8.1.0-canary.8 → 9.0.0-canary.54
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 +107 -0
- package/ConfigurableCartItem/ConfigurableCartItem.graphql +1 -1
- package/ConfigurableContext/ConfigurableProductForm.graphql +0 -1
- package/ConfigurableProductAddToCart/ConfigurableProductAddToCart.tsx +6 -8
- package/components/ProductListItemConfigurable/ProductListItemConfigurable.graphql +0 -15
- package/components/ProductListItemConfigurable/ProductListItemConfigurable.tsx +0 -37
- package/graphql/ConfigurableOptions.graphql +1 -1
- package/graphql/ConfigurableOptionsSelection.graphql +1 -1
- package/hooks/useConfigurableOptionsSelection.ts +1 -1
- package/package.json +18 -18
- package/plugins/ConfigurableCartItemActionCard.tsx +6 -6
- package/plugins/ConfigurableProductPage/ConfigurableProductPagePriceTiers.tsx +3 -2
- package/utils/defaultConfigurableOptionsSelection.ts +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,112 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.54
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.53
|
|
6
|
+
|
|
7
|
+
## 8.1.0-canary.52
|
|
8
|
+
|
|
9
|
+
## 8.1.0-canary.51
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#2322](https://github.com/graphcommerce-org/graphcommerce/pull/2322) [`4d08a2b`](https://github.com/graphcommerce-org/graphcommerce/commit/4d08a2bd8c1919bd85b18e8e856775d18fb67e00) - Rename configurable_customizable back to customizable_options
|
|
14
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
15
|
+
|
|
16
|
+
## 8.1.0-canary.50
|
|
17
|
+
|
|
18
|
+
## 8.1.0-canary.49
|
|
19
|
+
|
|
20
|
+
## 8.1.0-canary.48
|
|
21
|
+
|
|
22
|
+
## 8.1.0-canary.47
|
|
23
|
+
|
|
24
|
+
## 8.1.0-canary.46
|
|
25
|
+
|
|
26
|
+
## 8.1.0-canary.45
|
|
27
|
+
|
|
28
|
+
## 8.1.0-canary.44
|
|
29
|
+
|
|
30
|
+
## 8.1.0-canary.43
|
|
31
|
+
|
|
32
|
+
## 8.1.0-canary.42
|
|
33
|
+
|
|
34
|
+
## 8.1.0-canary.41
|
|
35
|
+
|
|
36
|
+
## 8.1.0-canary.40
|
|
37
|
+
|
|
38
|
+
## 8.1.0-canary.39
|
|
39
|
+
|
|
40
|
+
## 8.1.0-canary.38
|
|
41
|
+
|
|
42
|
+
## 8.1.0-canary.37
|
|
43
|
+
|
|
44
|
+
## 8.1.0-canary.36
|
|
45
|
+
|
|
46
|
+
## 8.1.0-canary.35
|
|
47
|
+
|
|
48
|
+
## 8.1.0-canary.34
|
|
49
|
+
|
|
50
|
+
## 8.1.0-canary.33
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#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
|
|
55
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
56
|
+
|
|
57
|
+
## 8.1.0-canary.32
|
|
58
|
+
|
|
59
|
+
## 8.1.0-canary.31
|
|
60
|
+
|
|
61
|
+
## 8.1.0-canary.30
|
|
62
|
+
|
|
63
|
+
## 8.1.0-canary.29
|
|
64
|
+
|
|
65
|
+
## 8.1.0-canary.28
|
|
66
|
+
|
|
67
|
+
## 8.1.0-canary.27
|
|
68
|
+
|
|
69
|
+
## 8.1.0-canary.26
|
|
70
|
+
|
|
71
|
+
## 8.1.0-canary.25
|
|
72
|
+
|
|
73
|
+
## 8.1.0-canary.24
|
|
74
|
+
|
|
75
|
+
## 8.1.0-canary.23
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- [#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.
|
|
80
|
+
([@carlocarels90](https://github.com/carlocarels90))
|
|
81
|
+
|
|
82
|
+
## 8.1.0-canary.22
|
|
83
|
+
|
|
84
|
+
## 8.1.0-canary.21
|
|
85
|
+
|
|
86
|
+
## 8.1.0-canary.20
|
|
87
|
+
|
|
88
|
+
## 8.1.0-canary.19
|
|
89
|
+
|
|
90
|
+
## 8.1.0-canary.18
|
|
91
|
+
|
|
92
|
+
## 8.1.0-canary.17
|
|
93
|
+
|
|
94
|
+
## 8.1.0-canary.16
|
|
95
|
+
|
|
96
|
+
## 8.1.0-canary.15
|
|
97
|
+
|
|
98
|
+
## 8.1.0-canary.14
|
|
99
|
+
|
|
100
|
+
## 8.1.0-canary.13
|
|
101
|
+
|
|
102
|
+
## 8.1.0-canary.12
|
|
103
|
+
|
|
104
|
+
## 8.1.0-canary.11
|
|
105
|
+
|
|
106
|
+
## 8.1.0-canary.10
|
|
107
|
+
|
|
108
|
+
## 8.1.0-canary.9
|
|
109
|
+
|
|
3
110
|
## 8.1.0-canary.8
|
|
4
111
|
|
|
5
112
|
### Patch Changes
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
MessageSnackbar,
|
|
9
9
|
IconSvg,
|
|
10
10
|
} from '@graphcommerce/next-ui'
|
|
11
|
-
import { Trans } from '@lingui/
|
|
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
|
|
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
|
|
175
|
+
<Trans>View shopping cart</Trans>
|
|
176
176
|
</Button>
|
|
177
177
|
}
|
|
178
178
|
>
|
|
179
|
-
<Trans
|
|
180
|
-
|
|
181
|
-
|
|
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
|
)
|
|
@@ -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}
|
|
@@ -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
|
|
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": "
|
|
5
|
+
"version": "9.0.0-canary.54",
|
|
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": "^
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
17
|
-
"@graphcommerce/graphql": "^
|
|
18
|
-
"@graphcommerce/graphql-mesh": "^
|
|
19
|
-
"@graphcommerce/image": "^
|
|
20
|
-
"@graphcommerce/lingui-next": "
|
|
21
|
-
"@graphcommerce/magento-cart": "^
|
|
22
|
-
"@graphcommerce/magento-cart-items": "^
|
|
23
|
-
"@graphcommerce/magento-category": "^
|
|
24
|
-
"@graphcommerce/magento-customer": "^
|
|
25
|
-
"@graphcommerce/magento-product": "^
|
|
26
|
-
"@graphcommerce/magento-product-simple": "^
|
|
27
|
-
"@graphcommerce/magento-store": "^
|
|
28
|
-
"@graphcommerce/next-ui": "^
|
|
29
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
30
|
-
"@graphcommerce/react-hook-form": "^
|
|
31
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.54",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.54",
|
|
17
|
+
"@graphcommerce/graphql": "^9.0.0-canary.54",
|
|
18
|
+
"@graphcommerce/graphql-mesh": "^9.0.0-canary.54",
|
|
19
|
+
"@graphcommerce/image": "^9.0.0-canary.54",
|
|
20
|
+
"@graphcommerce/lingui-next": "9.0.0-canary.54",
|
|
21
|
+
"@graphcommerce/magento-cart": "^9.0.0-canary.54",
|
|
22
|
+
"@graphcommerce/magento-cart-items": "^9.0.0-canary.54",
|
|
23
|
+
"@graphcommerce/magento-category": "^9.0.0-canary.54",
|
|
24
|
+
"@graphcommerce/magento-customer": "^9.0.0-canary.54",
|
|
25
|
+
"@graphcommerce/magento-product": "^9.0.0-canary.54",
|
|
26
|
+
"@graphcommerce/magento-product-simple": "^9.0.0-canary.54",
|
|
27
|
+
"@graphcommerce/magento-store": "^9.0.0-canary.54",
|
|
28
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.54",
|
|
29
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.54",
|
|
30
|
+
"@graphcommerce/react-hook-form": "^9.0.0-canary.54",
|
|
31
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.54",
|
|
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
|
|
7
|
-
|
|
6
|
+
export const config: PluginConfig = {
|
|
7
|
+
type: 'component',
|
|
8
|
+
module: '@graphcommerce/magento-cart-items',
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
export function
|
|
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
|
|
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
|
-
|
|
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 (!
|
|
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
|
],
|