diff --git a/.changeset/modern-suits-shop.md b/.changeset/modern-suits-shop.md new file mode 100644 index 0000000000..e400435510 --- /dev/null +++ b/.changeset/modern-suits-shop.md @@ -0,0 +1,6 @@ +--- +'@shopify/hydrogen-react': patch +'@shopify/hydrogen': patch +--- + +Update `` to remove deprecated code usage for `priceV2` and `compareAtPriceV2`. Remove export for `getCustomerPrivacy`. diff --git a/packages/hydrogen-react/src/CartProvider.test.helpers.ts b/packages/hydrogen-react/src/CartProvider.test.helpers.ts index 1adac37716..ba28c5cc55 100644 --- a/packages/hydrogen-react/src/CartProvider.test.helpers.ts +++ b/packages/hydrogen-react/src/CartProvider.test.helpers.ts @@ -16,7 +16,7 @@ export const CART_LINE: PartialDeep = { merchandise: { id: 'def', availableForSale: true, - priceV2: { + price: { amount: '123', currencyCode: 'USD', }, diff --git a/packages/hydrogen-react/src/Image.test.helpers.ts b/packages/hydrogen-react/src/Image.test.helpers.ts index 62b3b7e607..d2dd68ec89 100644 --- a/packages/hydrogen-react/src/Image.test.helpers.ts +++ b/packages/hydrogen-react/src/Image.test.helpers.ts @@ -14,8 +14,5 @@ export function getPreviewImage(image: Partial = {}): PartialDeep< url: image.url ?? faker.image.imageUrl(), width: image.width ?? faker.datatype.number(), height: image.height ?? faker.datatype.number(), - originalSrc: '', - transformedSrc: '', - src: '', }; } diff --git a/packages/hydrogen-react/src/ProductPrice.stories.tsx b/packages/hydrogen-react/src/ProductPrice.stories.tsx index 228f2b2d6c..aec6d15252 100644 --- a/packages/hydrogen-react/src/ProductPrice.stories.tsx +++ b/packages/hydrogen-react/src/ProductPrice.stories.tsx @@ -42,11 +42,11 @@ const Template: Story = (props) => { nodes: [ getVariant({ id: '123', - priceV2: { + price: { currencyCode: 'USD', amount: '300', }, - compareAtPriceV2: { + compareAtPrice: { currencyCode: 'USD', amount: '310', }, diff --git a/packages/hydrogen-react/src/ProductPrice.test.tsx b/packages/hydrogen-react/src/ProductPrice.test.tsx index 9d188f6083..072e452963 100644 --- a/packages/hydrogen-react/src/ProductPrice.test.tsx +++ b/packages/hydrogen-react/src/ProductPrice.test.tsx @@ -14,10 +14,6 @@ describe('', () => { expect( screen.getByText(variant?.price?.amount || '', {exact: false}), ).toBeInTheDocument(); - - expect( - screen.getByText(variant?.priceV2?.amount || '', {exact: false}), - ).toBeInTheDocument(); }); it("renders with the variant's minimum compareAt price", () => { @@ -51,12 +47,6 @@ describe('', () => { exact: false, }), ).toBeInTheDocument(); - - expect( - screen.getByText(variant?.compareAtPriceV2?.amount || '', { - exact: false, - }), - ).toBeInTheDocument(); }); it('renders with unit prices when valueType is `unit`', () => { diff --git a/packages/hydrogen-react/src/ProductPrice.tsx b/packages/hydrogen-react/src/ProductPrice.tsx index 736831ab4d..c89dfbd33e 100644 --- a/packages/hydrogen-react/src/ProductPrice.tsx +++ b/packages/hydrogen-react/src/ProductPrice.tsx @@ -49,30 +49,19 @@ export function ProductPrice< ) ?? null : null; - /** - * @deprecated (Next major release) Stop using compareAtPriceV2 and priceV2 - */ const variantPriceProperty = valueType === 'max' ? 'maxVariantPrice' : 'minVariantPrice'; if (priceType === 'compareAt') { if (variantId && variant) { - if (variant.compareAtPriceV2) { - console.error( - ' `compareAtPriceV2` is deprecated. Use `compareAtPrice` instead.', - ); - } - - price = variant.compareAtPrice ?? variant.compareAtPriceV2; + price = variant.compareAtPrice; } else { price = product?.compareAtPriceRange?.[variantPriceProperty]; } let priceAsNumber: number; if (variantId && variant) { - priceAsNumber = parseFloat( - variant.price?.amount ?? variant.priceV2?.amount ?? '0', - ); + priceAsNumber = parseFloat(variant.price?.amount ?? '0'); } else { priceAsNumber = parseFloat( product?.priceRange?.[variantPriceProperty]?.amount ?? '0', @@ -86,13 +75,7 @@ export function ProductPrice< } } else { if (variantId && variant) { - if (variant.priceV2) { - console.error( - ' `priceV2` is deprecated. Use `price` instead.', - ); - } - - price = variant.price ?? variant.priceV2; + price = variant.price; if (valueType === 'unit') { price = variant.unitPrice; measurement = variant.unitPriceMeasurement; diff --git a/packages/hydrogen-react/src/ProductProvider.test.helpers.ts b/packages/hydrogen-react/src/ProductProvider.test.helpers.ts index ec71654852..02c436e6f1 100644 --- a/packages/hydrogen-react/src/ProductProvider.test.helpers.ts +++ b/packages/hydrogen-react/src/ProductProvider.test.helpers.ts @@ -69,9 +69,7 @@ export function getVariant( variant?.unitPriceMeasurement ?? undefined, ), price, - priceV2: price, compareAtPrice, - compareAtPriceV2: compareAtPrice, selectedOptions: [ {name: faker.random.word(), value: faker.random.word()}, {name: faker.random.word(), value: faker.random.word()}, @@ -85,7 +83,7 @@ export function getVariant( }; } -const priceV2: MoneyV2 = { +const price: MoneyV2 = { amount: '9.99', currencyCode: 'CAD', }; @@ -109,9 +107,9 @@ export const VARIANTS: PartialDeep< }, ], availableForSale: true, - unitPrice: priceV2, + unitPrice: price, unitPriceMeasurement: getUnitPriceMeasurement(), - priceV2, + price, metafields: [], }, { @@ -128,9 +126,9 @@ export const VARIANTS: PartialDeep< }, ], availableForSale: true, - unitPrice: priceV2, + unitPrice: price, unitPriceMeasurement: getUnitPriceMeasurement(), - priceV2, + price, metafields: [], }, { @@ -147,9 +145,9 @@ export const VARIANTS: PartialDeep< }, ], availableForSale: true, - unitPrice: priceV2, + unitPrice: price, unitPriceMeasurement: getUnitPriceMeasurement(), - priceV2, + price, metafields: [], }, { @@ -166,9 +164,9 @@ export const VARIANTS: PartialDeep< }, ], availableForSale: false, - unitPrice: priceV2, + unitPrice: price, unitPriceMeasurement: getUnitPriceMeasurement(), - priceV2, + price, metafields: [], }, ], diff --git a/packages/hydrogen/src/customer-privacy/useCustomerPrivacy.doc.ts b/packages/hydrogen/src/customer-privacy/useCustomerPrivacy.doc.ts index b1a5c62362..959e0a5ea5 100644 --- a/packages/hydrogen/src/customer-privacy/useCustomerPrivacy.doc.ts +++ b/packages/hydrogen/src/customer-privacy/useCustomerPrivacy.doc.ts @@ -6,7 +6,7 @@ const data: ReferenceEntityTemplateSchema = { isVisualComponent: false, related: [], description: - 'A hook that loads the [Customer Privacy API](/docs/api/customer-privacy).\n\nYou can get the customer privacy instance with `getCustomerPrivacy()`.\n\nYou can also listen to a `document` event for `shopifyCustomerPrivacyApiLoaded`. It will be emitted when the Customer Privacy API is loaded.', + 'A hook that loads the [Customer Privacy API](/docs/api/customer-privacy).\n\nYou can also listen to a `document` event for `shopifyCustomerPrivacyApiLoaded`. It will be emitted when the Customer Privacy API is loaded.', type: 'hook', defaultExample: { description: 'This is the default example', @@ -37,7 +37,7 @@ const data: ReferenceEntityTemplateSchema = { description: 'Example usage with `useAnalytics`:', exampleGroups: [ { - title: 'getCustomerPrivacy', + title: 'useCustomerPrivacy', examples: [ { description: diff --git a/packages/hydrogen/src/index.ts b/packages/hydrogen/src/index.ts index 13d360633e..0e75930b18 100644 --- a/packages/hydrogen/src/index.ts +++ b/packages/hydrogen/src/index.ts @@ -116,10 +116,6 @@ export { type CustomEventMap, type CustomerPrivacyApiProps, useCustomerPrivacy, - /* - @deprecated use useAnalytics or useCustomerPrivacy instead - */ - getCustomerPrivacy, } from './customer-privacy/ShopifyCustomerPrivacy'; export {