@graphcommerce/magento-product-configurable 8.1.0-canary.3 → 8.1.0-canary.5
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 +77 -2
- package/ConfigurableProductAddToCart/ConfigurableProductAddToCart.tsx +6 -4
- package/components/ConfigurableProductOptions/ConfigurableProductOptions.tsx +8 -3
- package/graphql/GetConfigurableOptionsSelection.graphql +1 -6
- package/package.json +18 -18
- package/plugins/ConfigurableCartItemActionCard.tsx +3 -6
- package/plugins/ConfigurableProductPage/ConfigurableProductPageDescription.tsx +9 -7
- package/plugins/ConfigurableProductPage/ConfigurableProductPageGallery.tsx +6 -7
- package/plugins/ConfigurableProductPage/ConfigurableProductPageJsonLd.tsx +14 -7
- package/plugins/ConfigurableProductPage/ConfigurableProductPageMeta.tsx +6 -6
- package/plugins/ConfigurableProductPage/ConfigurableProductPageName.tsx +6 -6
- package/plugins/ConfigurableProductPage/ConfigurableProductPagePrice.tsx +15 -8
- package/plugins/ConfigurableProductPage/ConfigurableProductPagePriceTiers.tsx +9 -7
- package/plugins/ConfigurableProductPage/ConfigurableProductShortDescription.tsx +9 -7
- package/utils/defaultConfigurableOptionsSelection.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,83 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 8.1.0-canary.
|
|
3
|
+
## 8.1.0-canary.5
|
|
4
4
|
|
|
5
|
-
## 8.
|
|
5
|
+
## 8.0.6-canary.4
|
|
6
|
+
|
|
7
|
+
## 8.0.6-canary.3
|
|
8
|
+
|
|
9
|
+
## 8.0.6-canary.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
|
|
14
|
+
([@FrankHarland](https://github.com/FrankHarland))
|
|
15
|
+
|
|
16
|
+
## 8.0.6-canary.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#2213](https://github.com/graphcommerce-org/graphcommerce/pull/2213) [`a0d952e`](https://github.com/graphcommerce-org/graphcommerce/commit/a0d952e6b8a71a7451bfdb2bdb5150fc218169e2) - Moved product reviews to the relatedUpsells query so we do not pass the queryComplexity limit
|
|
21
|
+
([@paales](https://github.com/paales))
|
|
22
|
+
|
|
23
|
+
## 8.0.6-canary.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#2196](https://github.com/graphcommerce-org/graphcommerce/pull/2196) [`84c50e4`](https://github.com/graphcommerce-org/graphcommerce/commit/84c50e49a1a7f154d4a8f4045c37e773e20283ad) - Allow Lingui to use linguiLocale with country identifiers like `en-us`, it would always load `en` in this case. Introced a new `useLocale` hook to use the correct locale string to use in Intl methods.
|
|
28
|
+
([@paales](https://github.com/paales))
|
|
29
|
+
|
|
30
|
+
## 8.0.5
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#2239](https://github.com/graphcommerce-org/graphcommerce/pull/2239) [`a2a6e78`](https://github.com/graphcommerce-org/graphcommerce/commit/a2a6e78291ab978f4ef1236a4476b4d54555af7f) - Prices of products are now updated when customizable options are selected
|
|
35
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
36
|
+
|
|
37
|
+
## 8.0.5-canary.10
|
|
38
|
+
|
|
39
|
+
## 8.0.5-canary.9
|
|
40
|
+
|
|
41
|
+
## 8.0.5-canary.8
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- [#2239](https://github.com/graphcommerce-org/graphcommerce/pull/2239) [`a2a6e78`](https://github.com/graphcommerce-org/graphcommerce/commit/a2a6e78291ab978f4ef1236a4476b4d54555af7f) - Prices of products are now updated when customizable options are selected
|
|
46
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
47
|
+
|
|
48
|
+
## 8.0.5-canary.7
|
|
49
|
+
|
|
50
|
+
## 8.0.5-canary.6
|
|
51
|
+
|
|
52
|
+
## 8.0.5-canary.5
|
|
53
|
+
|
|
54
|
+
## 8.0.5-canary.4
|
|
55
|
+
|
|
56
|
+
## 8.0.5-canary.3
|
|
57
|
+
|
|
58
|
+
## 8.0.5-canary.2
|
|
59
|
+
|
|
60
|
+
## 8.0.5-canary.1
|
|
61
|
+
|
|
62
|
+
## 8.0.5-canary.0
|
|
63
|
+
|
|
64
|
+
## 8.0.4
|
|
65
|
+
|
|
66
|
+
## 8.0.4-canary.1
|
|
67
|
+
|
|
68
|
+
## 8.0.4-canary.0
|
|
69
|
+
|
|
70
|
+
## 8.0.3
|
|
71
|
+
|
|
72
|
+
## 8.0.3-canary.6
|
|
73
|
+
|
|
74
|
+
## 8.0.3-canary.5
|
|
75
|
+
|
|
76
|
+
## 8.0.3-canary.4
|
|
77
|
+
|
|
78
|
+
## 8.0.3-canary.3
|
|
79
|
+
|
|
80
|
+
## 8.0.3-canary.2
|
|
6
81
|
|
|
7
82
|
## 8.0.3-canary.1
|
|
8
83
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberFieldElement } from '@graphcommerce/ecommerce-ui'
|
|
1
2
|
import { ApolloCartErrorAlert, useFormGqlMutationCart } from '@graphcommerce/magento-cart'
|
|
2
3
|
import { Money } from '@graphcommerce/magento-store'
|
|
3
4
|
import {
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
iconChevronRight,
|
|
7
8
|
MessageSnackbar,
|
|
8
9
|
IconSvg,
|
|
9
|
-
TextInputNumber,
|
|
10
10
|
} from '@graphcommerce/next-ui'
|
|
11
11
|
import { Trans } from '@lingui/react'
|
|
12
12
|
import { Divider, Typography, Alert, Box, SxProps, Theme } from '@mui/material'
|
|
@@ -64,7 +64,7 @@ export function ConfigurableProductAddToCart(props: ConfigurableProductAddToCart
|
|
|
64
64
|
}),
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
const { handleSubmit, formState,
|
|
67
|
+
const { handleSubmit, formState, required, control, error, data } = form
|
|
68
68
|
const submitHandler = handleSubmit(() => {})
|
|
69
69
|
|
|
70
70
|
return (
|
|
@@ -91,12 +91,14 @@ export function ConfigurableProductAddToCart(props: ConfigurableProductAddToCart
|
|
|
91
91
|
{...optionsProps}
|
|
92
92
|
/>
|
|
93
93
|
|
|
94
|
-
<
|
|
94
|
+
<NumberFieldElement
|
|
95
95
|
variant='outlined'
|
|
96
96
|
error={formState.isSubmitted && !!formState.errors.quantity}
|
|
97
97
|
required={required.quantity}
|
|
98
98
|
inputProps={{ min: 1 }}
|
|
99
|
-
|
|
99
|
+
name='quantity'
|
|
100
|
+
rules={{ required: required.quantity }}
|
|
101
|
+
control={control}
|
|
100
102
|
helperText={formState.isSubmitted && formState.errors.quantity?.message}
|
|
101
103
|
// disabled={loading}
|
|
102
104
|
size='small'
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { normalizeLocale } from '@graphcommerce/lingui-next'
|
|
2
2
|
import { AddToCartItemSelector, useFormAddProductsToCart } from '@graphcommerce/magento-product'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
filterNonNullableKeys,
|
|
5
|
+
ActionCardListProps,
|
|
6
|
+
useStorefrontConfig,
|
|
7
|
+
useLocale,
|
|
8
|
+
} from '@graphcommerce/next-ui'
|
|
4
9
|
import { i18n } from '@lingui/core'
|
|
5
10
|
import { Box, SxProps, Theme } from '@mui/material'
|
|
6
11
|
import { useRouter } from 'next/router'
|
|
@@ -27,7 +32,6 @@ export function ConfigurableProductOptions(props: ConfigurableProductOptionsProp
|
|
|
27
32
|
...other
|
|
28
33
|
} = props
|
|
29
34
|
const { setError, clearErrors } = useFormAddProductsToCart()
|
|
30
|
-
const { locale } = useRouter()
|
|
31
35
|
|
|
32
36
|
const options = filterNonNullableKeys(product.configurable_options, [
|
|
33
37
|
'attribute_code',
|
|
@@ -41,8 +45,9 @@ export function ConfigurableProductOptions(props: ConfigurableProductOptionsProp
|
|
|
41
45
|
(configured?.configurable_product_options_selection?.options_available_for_selection ?? [])
|
|
42
46
|
.length === 0
|
|
43
47
|
|
|
48
|
+
const locale = useLocale()
|
|
44
49
|
const allLabels = useMemo(() => {
|
|
45
|
-
const formatter = new Intl.ListFormat(
|
|
50
|
+
const formatter = new Intl.ListFormat(locale, {
|
|
46
51
|
style: 'long',
|
|
47
52
|
type: 'conjunction',
|
|
48
53
|
})
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
query GetConfigurableOptionsSelection(
|
|
2
|
-
$urlKey: String!
|
|
3
|
-
$selectedOptions: [ID!] = []
|
|
4
|
-
$reviewPageSize: Int = 3
|
|
5
|
-
$reviewPage: Int = 1
|
|
6
|
-
) {
|
|
1
|
+
query GetConfigurableOptionsSelection($urlKey: String!, $selectedOptions: [ID!] = []) {
|
|
7
2
|
products(filter: { url_key: { eq: $urlKey } }) {
|
|
8
3
|
__typename
|
|
9
4
|
items {
|
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
|
+
"version": "8.1.0-canary.5",
|
|
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.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
17
|
-
"@graphcommerce/graphql": "^8.1.0-canary.
|
|
18
|
-
"@graphcommerce/graphql-mesh": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/image": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/lingui-next": "8.1.0-canary.
|
|
21
|
-
"@graphcommerce/magento-cart": "^8.1.0-canary.
|
|
22
|
-
"@graphcommerce/magento-cart-items": "^8.1.0-canary.
|
|
23
|
-
"@graphcommerce/magento-category": "^8.1.0-canary.
|
|
24
|
-
"@graphcommerce/magento-customer": "^8.1.0-canary.
|
|
25
|
-
"@graphcommerce/magento-product": "^8.1.0-canary.
|
|
26
|
-
"@graphcommerce/magento-product-simple": "^8.1.0-canary.
|
|
27
|
-
"@graphcommerce/magento-store": "^8.1.0-canary.
|
|
28
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
29
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
30
|
-
"@graphcommerce/react-hook-form": "^8.1.0-canary.
|
|
31
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
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",
|
|
32
32
|
"@lingui/core": "^4.2.1",
|
|
33
33
|
"@lingui/macro": "^4.2.1",
|
|
34
34
|
"@lingui/react": "^4.2.1",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CartItemActionCardProps } from '@graphcommerce/magento-cart-items'
|
|
2
2
|
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { isTypename } from '@graphcommerce/next-ui'
|
|
4
4
|
import { ConfigurableCartItemOptions } from '../components'
|
|
5
5
|
|
|
6
6
|
export const component = 'CartItemActionCard'
|
|
7
|
-
export const exported =
|
|
8
|
-
'@graphcommerce/magento-cart-items/components/CartItemActionCard/CartItemActionCard'
|
|
7
|
+
export const exported = '@graphcommerce/magento-cart-items'
|
|
9
8
|
|
|
10
|
-
export function ConfigurableCartItemActionCard(
|
|
11
|
-
props: PluginProps<React.ComponentProps<typeof CartItemActionCard>>,
|
|
12
|
-
) {
|
|
9
|
+
export function ConfigurableCartItemActionCard(props: PluginProps<CartItemActionCardProps>) {
|
|
13
10
|
const { Prev, ...rest } = props
|
|
14
11
|
|
|
15
12
|
if (!isTypename(rest.cartItem, ['ConfigurableCartItem'])) return <Prev {...rest} />
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AddToCartItemSelector,
|
|
3
|
+
ProductPageDescriptionProps,
|
|
4
|
+
} from '@graphcommerce/magento-product'
|
|
5
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
6
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
7
|
|
|
5
8
|
export const component = 'ProductPageDescription'
|
|
6
|
-
export const exported =
|
|
7
|
-
'@graphcommerce/magento-product/components/ProductPageDescription/ProductPageDescription'
|
|
9
|
+
export const exported = '@graphcommerce/magento-product'
|
|
8
10
|
export const ifConfig: IfConfig = 'configurableVariantValues.content'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
export const ConfigurableProductPageDescription = (
|
|
13
|
+
props: PluginProps<ProductPageDescriptionProps & AddToCartItemSelector>,
|
|
14
|
+
) => {
|
|
13
15
|
const { Prev, product, index, ...rest } = props
|
|
14
16
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
|
|
15
17
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { AddToCartItemSelector,
|
|
2
|
-
import type {
|
|
1
|
+
import type { AddToCartItemSelector, ProductPageGalleryProps } from '@graphcommerce/magento-product'
|
|
2
|
+
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useConfigurableOptionsSelection } from '../../hooks'
|
|
4
4
|
|
|
5
5
|
export const component = 'ProductPageGallery'
|
|
6
|
-
export const exported =
|
|
7
|
-
'@graphcommerce/magento-product/components/ProductPageGallery/ProductPageGallery'
|
|
6
|
+
export const exported = '@graphcommerce/magento-product'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const ConfigurableProductPageGallery = (
|
|
9
|
+
props: PluginProps<ProductPageGalleryProps> & AddToCartItemSelector,
|
|
10
|
+
) => {
|
|
12
11
|
const { Prev, product, index, ...rest } = props
|
|
13
12
|
|
|
14
13
|
const { configured } = useConfigurableOptionsSelection({ url_key: product.url_key, index })
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AddToCartItemSelector,
|
|
3
|
+
JsonLdProductFragment,
|
|
4
|
+
ProductPageJsonLdProps,
|
|
5
|
+
} from '@graphcommerce/magento-product'
|
|
6
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
7
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
8
|
|
|
5
9
|
export const component = 'ProductPageJsonLd'
|
|
6
|
-
export const exported = '@graphcommerce/magento-product
|
|
10
|
+
export const exported = '@graphcommerce/magento-product'
|
|
7
11
|
export const ifConfig: IfConfig = 'configurableVariantValues.content'
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
const ConfigurableProductPageJsonLd = <
|
|
14
|
+
T extends { '@type': string },
|
|
15
|
+
P extends JsonLdProductFragment,
|
|
16
|
+
>(
|
|
17
|
+
props: PluginProps<ProductPageJsonLdProps<T, P>> & AddToCartItemSelector,
|
|
18
|
+
) => {
|
|
12
19
|
const { Prev, product, index, ...rest } = props
|
|
13
20
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
|
|
14
|
-
return <Prev product={variant ?? product} {...rest} />
|
|
21
|
+
return <Prev product={(variant ?? product) as P} {...rest} />
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
export const Plugin = ConfigurableProductPageJsonLd
|
|
@@ -2,20 +2,20 @@ import { mergeDeep } from '@graphcommerce/graphql'
|
|
|
2
2
|
import {
|
|
3
3
|
productLink,
|
|
4
4
|
type AddToCartItemSelector,
|
|
5
|
-
|
|
5
|
+
ProductPageMetaProps,
|
|
6
6
|
} from '@graphcommerce/magento-product'
|
|
7
|
-
import type { IfConfig,
|
|
7
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
8
8
|
import { useRouter } from 'next/router'
|
|
9
9
|
import { useEffect } from 'react'
|
|
10
10
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
11
11
|
|
|
12
12
|
export const component = 'ProductPageMeta'
|
|
13
|
-
export const exported = '@graphcommerce/magento-product
|
|
13
|
+
export const exported = '@graphcommerce/magento-product'
|
|
14
14
|
export const ifConfig: IfConfig = 'configurableVariantValues.url'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const ConfigurableProductPageMetaUrls = (
|
|
17
|
+
props: PluginProps<ProductPageMetaProps> & AddToCartItemSelector,
|
|
18
|
+
) => {
|
|
19
19
|
const { Prev, product, index, ...rest } = props
|
|
20
20
|
const { replace, asPath } = useRouter()
|
|
21
21
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { AddToCartItemSelector,
|
|
2
|
-
import type { IfConfig,
|
|
1
|
+
import type { AddToCartItemSelector, ProductPageNameProps } from '@graphcommerce/magento-product'
|
|
2
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
4
|
|
|
5
5
|
export const component = 'ProductPageName'
|
|
6
|
-
export const exported = '@graphcommerce/magento-product
|
|
6
|
+
export const exported = '@graphcommerce/magento-product'
|
|
7
7
|
export const ifConfig: IfConfig = 'configurableVariantValues.content'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const ConfigurableProductPageName = (
|
|
10
|
+
props: PluginProps<ProductPageNameProps> & AddToCartItemSelector,
|
|
11
|
+
) => {
|
|
12
12
|
const { Prev, product, index, ...rest } = props
|
|
13
13
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
|
|
14
14
|
return <Prev product={variant ?? product} {...rest} />
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { AddToCartItemSelector,
|
|
2
|
-
import type {
|
|
1
|
+
import { AddToCartItemSelector, ProductPagePriceProps } from '@graphcommerce/magento-product'
|
|
2
|
+
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
4
|
|
|
5
5
|
export const component = 'ProductPagePrice'
|
|
6
|
-
export const exported =
|
|
7
|
-
'@graphcommerce/magento-product/components/ProductPagePrice/ProductPagePrice'
|
|
6
|
+
export const exported = '@graphcommerce/magento-product'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const ConfigurableProductPagePrice = (
|
|
9
|
+
props: PluginProps<ProductPagePriceProps> & AddToCartItemSelector,
|
|
10
|
+
) => {
|
|
12
11
|
const { Prev, product, index, ...rest } = props
|
|
13
12
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
if (product.__typename !== 'ConfigurableProduct') return <Prev {...props} />
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Prev
|
|
18
|
+
product={variant ? { ...variant, options: product.options } : product}
|
|
19
|
+
index={index}
|
|
20
|
+
{...rest}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
export const Plugin = ConfigurableProductPagePrice
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AddToCartItemSelector,
|
|
3
|
+
ProductPagePriceTiersProps,
|
|
4
|
+
} from '@graphcommerce/magento-product'
|
|
5
|
+
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
6
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
7
|
|
|
5
8
|
export const component = 'ProductPagePriceTiers'
|
|
6
|
-
export const exported =
|
|
7
|
-
'@graphcommerce/magento-product/components/ProductPagePrice/ProductPagePriceTiers'
|
|
9
|
+
export const exported = '@graphcommerce/magento-product'
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const ConfigurableProductPagePriceTiers = (
|
|
12
|
+
props: PluginProps<ProductPagePriceTiersProps> & AddToCartItemSelector,
|
|
13
|
+
) => {
|
|
12
14
|
const { Prev, product, index, ...rest } = props
|
|
13
15
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index })
|
|
14
16
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AddToCartItemSelector,
|
|
3
|
+
ProductShortDescriptionProps,
|
|
4
|
+
} from '@graphcommerce/magento-product'
|
|
5
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
6
|
import { useConfigurableSelectedVariant } from '../../hooks'
|
|
4
7
|
|
|
5
8
|
export const component = 'ProductShortDescription'
|
|
6
|
-
export const exported =
|
|
7
|
-
'@graphcommerce/magento-product/components/ProductShortDescription/ProductShortDescription'
|
|
9
|
+
export const exported = '@graphcommerce/magento-product'
|
|
8
10
|
export const ifConfig: IfConfig = 'configurableVariantValues.content'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const ConfigurableProductShortDescription = (
|
|
13
|
+
props: PluginProps<ProductShortDescriptionProps> & AddToCartItemSelector,
|
|
14
|
+
) => {
|
|
13
15
|
const { Prev, product, ...rest } = props
|
|
14
16
|
const variant = useConfigurableSelectedVariant({ url_key: product.url_key, index: 0 })
|
|
15
17
|
|
|
@@ -40,8 +40,9 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
|
|
|
40
40
|
return { ...query, defaultValues: {} }
|
|
41
41
|
|
|
42
42
|
// Find the requested simple product on the configurable variants and get the attributes.
|
|
43
|
-
const attributes = configurable?.variants?.find(
|
|
44
|
-
?.
|
|
43
|
+
const attributes = configurable?.variants?.find(
|
|
44
|
+
(v) => v?.product?.uid === simple?.uid,
|
|
45
|
+
)?.attributes
|
|
45
46
|
|
|
46
47
|
const selectedOptions = (attributes ?? []).filter(nonNullable).map((a) => a.uid)
|
|
47
48
|
if (!selectedOptions.length)
|
|
@@ -72,7 +73,7 @@ export function defaultConfigurableOptionsSelection<Q extends BaseQuery = BaseQu
|
|
|
72
73
|
|
|
73
74
|
client.cache.writeQuery({
|
|
74
75
|
query: GetConfigurableOptionsSelectionDocument,
|
|
75
|
-
variables: { urlKey: configurable.url_key, selectedOptions
|
|
76
|
+
variables: { urlKey: configurable.url_key, selectedOptions },
|
|
76
77
|
data: {
|
|
77
78
|
products: {
|
|
78
79
|
...query?.products,
|