diff --git a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx index cf2fe1319..7af12ed0b 100644 --- a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx +++ b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx @@ -28,7 +28,7 @@ import ProductVariantPrice from "../ProductVariantPrice"; interface ProductVariantCreatePageFormData { costPrice: string; images: string[]; - priceOverride: string; + price: string; quantity: string; sku: string; trackInventory: boolean; @@ -83,7 +83,7 @@ const ProductVariantCreatePage: React.FC = ({ const initialForm: ProductVariantCreatePageFormData = { costPrice: "", images: maybe(() => product.images.map(image => image.id)), - priceOverride: "", + price: "", quantity: "0", sku: "", trackInventory: true @@ -130,7 +130,7 @@ const ProductVariantCreatePage: React.FC = ({ error => error.index === variantIndex ); const variantFormErrors = getFormErrors( - ["priceOverride", "quantity", "sku"], + ["price", "quantity", "sku"], variantErrors ); @@ -234,9 +234,9 @@ const ProductVariantCreatorSummary: React.FC endAdornment: currencySymbol }} className={classes.input} - error={!!variantFormErrors.priceOverride} + error={!!variantFormErrors.price} helperText={getBulkProductErrorMessage( - variantFormErrors.priceOverride, + variantFormErrors.price, intl )} inputProps={{ @@ -244,7 +244,7 @@ const ProductVariantCreatorSummary: React.FC type: "number" }} fullWidth - value={variant.priceOverride} + value={variant.price} onChange={event => onVariantDataChange( variantIndex, diff --git a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap index 32a195361..23447aca2 100644 --- a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap +++ b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap @@ -87,7 +87,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -129,7 +129,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -171,7 +171,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -213,7 +213,7 @@ Object { ], }, ], - "priceOverride": "49.99", + "price": "49.99", "sku": "", "stocks": Array [ Object { @@ -255,7 +255,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -297,7 +297,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -339,7 +339,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -381,7 +381,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -499,7 +499,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -541,7 +541,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -583,7 +583,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -625,7 +625,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -667,7 +667,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -709,7 +709,7 @@ Object { ], }, ], - "priceOverride": "24.99", + "price": "24.99", "sku": "", "stocks": Array [ Object { @@ -751,7 +751,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -793,7 +793,7 @@ Object { ], }, ], - "priceOverride": "26.99", + "price": "26.99", "sku": "", "stocks": Array [ Object { @@ -930,7 +930,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -972,7 +972,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1014,7 +1014,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1056,7 +1056,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1098,7 +1098,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1140,7 +1140,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1182,7 +1182,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1224,7 +1224,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1328,7 +1328,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1370,7 +1370,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1412,7 +1412,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1454,7 +1454,7 @@ Object { ], }, ], - "priceOverride": "45.99", + "price": "45.99", "sku": "", "stocks": Array [ Object { @@ -1496,7 +1496,7 @@ Object { ], }, ], - "priceOverride": "51.99", + "price": "51.99", "sku": "", "stocks": Array [ Object { @@ -1538,7 +1538,7 @@ Object { ], }, ], - "priceOverride": "51.99", + "price": "51.99", "sku": "", "stocks": Array [ Object { @@ -1580,7 +1580,7 @@ Object { ], }, ], - "priceOverride": "51.99", + "price": "51.99", "sku": "", "stocks": Array [ Object { @@ -1622,7 +1622,7 @@ Object { ], }, ], - "priceOverride": "51.99", + "price": "51.99", "sku": "", "stocks": Array [ Object { @@ -1717,7 +1717,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1759,7 +1759,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1801,7 +1801,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1843,7 +1843,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1885,7 +1885,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1927,7 +1927,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -1969,7 +1969,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2011,7 +2011,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2119,7 +2119,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2149,7 +2149,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2179,7 +2179,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2209,7 +2209,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2239,7 +2239,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2269,7 +2269,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2299,7 +2299,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { @@ -2329,7 +2329,7 @@ Object { ], }, ], - "priceOverride": "10.99", + "price": "10.99", "sku": "", "stocks": Array [ Object { diff --git a/src/products/components/ProductVariantCreatorPage/createVariants.test.ts b/src/products/components/ProductVariantCreatorPage/createVariants.test.ts index 9fbcd609d..e0319c1ab 100644 --- a/src/products/components/ProductVariantCreatorPage/createVariants.test.ts +++ b/src/products/components/ProductVariantCreatorPage/createVariants.test.ts @@ -43,7 +43,7 @@ describe("Creates variant matrix", () => { ); variants.forEach(variant => { - expect(variant.priceOverride).toBe(price); + expect(variant.price).toBe(price); variant.stocks.forEach((_, stockIndex) => { expect(variant.stocks[stockIndex].quantity).toBe(stock[stockIndex]); }); @@ -98,7 +98,7 @@ describe("Creates variant matrix", () => { ).values[0] === attributeValue ) .forEach(variant => { - expect(variant.priceOverride).toBe( + expect(variant.price).toBe( (price * (attributeValueIndex + 1)).toString() ); }); @@ -141,7 +141,7 @@ describe("Creates variant matrix", () => { ); variants.forEach(variant => { - expect(variant.priceOverride).toBe(price); + expect(variant.price).toBe(price); }); attribute.values.forEach((attributeValue, attributeValueIndex) => { @@ -210,7 +210,7 @@ describe("Creates variant matrix", () => { ).values[0] === attributeValue ) .forEach(variant => { - expect(variant.priceOverride).toBe( + expect(variant.price).toBe( (price * (attributeValueIndex + 1)).toString() ); }); diff --git a/src/products/components/ProductVariantCreatorPage/createVariants.ts b/src/products/components/ProductVariantCreatorPage/createVariants.ts index 75539f55a..462be5760 100644 --- a/src/products/components/ProductVariantCreatorPage/createVariants.ts +++ b/src/products/components/ProductVariantCreatorPage/createVariants.ts @@ -46,7 +46,7 @@ function createVariant( data: ProductVariantCreateFormData, attributes: CreateVariantInput ): ProductVariantBulkCreateInput { - const priceOverride = getValueFromMode(attributes, data.price, "0"); + const price = getValueFromMode(attributes, data.price, "0"); const stocks = getValueFromMode( attributes, data.stock, @@ -58,7 +58,7 @@ function createVariant( id: attribute.attributeId, values: [attribute.attributeValueSlug] })), - priceOverride, + price, sku: "", stocks: stocks.map((quantity, stockIndex) => ({ quantity, diff --git a/src/products/components/ProductVariantCreatorPage/reducer.test.ts b/src/products/components/ProductVariantCreatorPage/reducer.test.ts index 810eb35d5..ce6f8debf 100644 --- a/src/products/components/ProductVariantCreatorPage/reducer.test.ts +++ b/src/products/components/ProductVariantCreatorPage/reducer.test.ts @@ -250,9 +250,9 @@ describe("Reducer is able to", () => { } ]); - expect(state.variants[variantIndex].priceOverride).toBe(value); - expect(state.variants[variantIndex - 1].priceOverride).toBe( - fourthStep.variants[variantIndex - 1].priceOverride + expect(state.variants[variantIndex].price).toBe(value); + expect(state.variants[variantIndex - 1].price).toBe( + fourthStep.variants[variantIndex - 1].price ); expect(state).toMatchSnapshot(); }); diff --git a/src/products/components/ProductVariantCreatorPage/reducer.ts b/src/products/components/ProductVariantCreatorPage/reducer.ts index acc547b46..5f702218c 100644 --- a/src/products/components/ProductVariantCreatorPage/reducer.ts +++ b/src/products/components/ProductVariantCreatorPage/reducer.ts @@ -301,7 +301,7 @@ function changeVariantData( ...state.variants[variantIndex] }; if (field === "price") { - variant.priceOverride = value; + variant.price = value; } else if (field === "sku") { variant.sku = value; } diff --git a/src/products/components/ProductVariantPage/ProductVariantPage.tsx b/src/products/components/ProductVariantPage/ProductVariantPage.tsx index 54fb76fa6..a1d66af03 100644 --- a/src/products/components/ProductVariantPage/ProductVariantPage.tsx +++ b/src/products/components/ProductVariantPage/ProductVariantPage.tsx @@ -32,7 +32,7 @@ import ProductVariantPrice from "../ProductVariantPrice"; export interface ProductVariantPageFormData { costPrice: string; - priceOverride: string; + price: string; sku: string; trackInventory: boolean; } @@ -110,7 +110,7 @@ const ProductVariantPage: React.FC = ({ const initialForm: ProductVariantPageFormData = { costPrice: maybe(() => variant.costPrice.amount.toString(), ""), - priceOverride: maybe(() => variant.priceOverride.amount.toString(), ""), + price: maybe(() => variant.price.amount.toString(), ""), sku: maybe(() => variant.sku, ""), trackInventory: variant?.trackInventory }; @@ -182,10 +182,10 @@ const ProductVariantPage: React.FC = ({ = props => { - const { - currencySymbol, - costPrice, - errors, - priceOverride, - loading, - onChange - } = props; + const { currencySymbol, costPrice, errors, price, loading, onChange } = props; const classes = useStyles(props); const intl = useIntl(); @@ -56,7 +49,7 @@ const ProductVariantPrice: React.FC = props => {
= props => { intl.formatMessage({ defaultMessage: "Optional", description: "optional field", - id: "productVariantPriceOptionalPriceOverrideField" + id: "productVariantPriceOptionalPriceField" }) } - value={priceOverride} + value={price} currencySymbol={currencySymbol} onChange={onChange} disabled={loading} diff --git a/src/products/components/ProductVariants/ProductVariants.tsx b/src/products/components/ProductVariants/ProductVariants.tsx index aebec84bd..2370235dd 100644 --- a/src/products/components/ProductVariants/ProductVariants.tsx +++ b/src/products/components/ProductVariants/ProductVariants.tsx @@ -327,8 +327,8 @@ export const ProductVariants: React.FC = props => { {variant ? ( - variant.priceOverride ? ( - + variant.price ? ( + ) : fallbackPrice ? ( ) : ( diff --git a/src/products/fixtures.ts b/src/products/fixtures.ts index 04d2767e1..5d960fda2 100644 --- a/src/products/fixtures.ts +++ b/src/products/fixtures.ts @@ -256,7 +256,7 @@ export const product: ( ], margin: 2, name: "Cordoba Oro", - priceOverride: { + price: { __typename: "Money", amount: 678.78, currency: "USD" @@ -297,7 +297,7 @@ export const product: ( ], margin: 7, name: "silver", - priceOverride: null, + price: null, sku: "69055-15190", stocks: [ { @@ -1121,7 +1121,7 @@ export const variant = (placeholderImage: string): ProductVariant => ({ } ], name: "Extended Hard", - priceOverride: { + price: { __typename: "Money", amount: 100, currency: "USD" diff --git a/src/products/views/ProductVariant.tsx b/src/products/views/ProductVariant.tsx index 5891021d7..f339f80d2 100644 --- a/src/products/views/ProductVariant.tsx +++ b/src/products/views/ProductVariant.tsx @@ -155,7 +155,7 @@ export const ProductVariant: React.FC = ({ })), costPrice: decimal(data.costPrice), id: variantId, - priceOverride: decimal(data.priceOverride), + price: decimal(data.price), removeStocks: data.removeStocks, sku: data.sku, stocks: data.updateStocks.map( diff --git a/src/products/views/ProductVariantCreate.tsx b/src/products/views/ProductVariantCreate.tsx index 3598e7ddf..94178a6d2 100644 --- a/src/products/views/ProductVariantCreate.tsx +++ b/src/products/views/ProductVariantCreate.tsx @@ -75,7 +75,7 @@ export const ProductVariant: React.FC = ({ values: [attribute.value] })), costPrice: decimal(formData.costPrice), - priceOverride: decimal(formData.priceOverride), + price: decimal(formData.price), product: productId, sku: formData.sku, stocks: formData.stocks.map(stock => ({ diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 52aaa5a23..fef36ba5a 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -105754,109 +105754,6 @@ Ctrl + K"
-
-
- - Pricing - -
-
-
- -
-
-
-
-
- -
- -
-
- USD -
-
- -
-
-
-
-
-
@@ -106719,106 +106616,6 @@ Ctrl + K"
-
-
- - Pricing - -
-
-
- -
-
-
-
-
- -
- -
-
- USD -
-
- -
-
-
-
-
-
@@ -107680,106 +107477,6 @@ Ctrl + K"
-
-
- - Pricing - -
-
-
- -
-
-
-
-
- -
- -
-
- USD -
-
- -
-
-
-
-
-
@@ -108490,7 +108187,7 @@ exports[`Storyshots Views / Products / Create product variant add first variant @@ -109084,7 +108781,7 @@ exports[`Storyshots Views / Products / Create product variant default 1`] = ` @@ -109601,7 +109298,7 @@ exports[`Storyshots Views / Products / Create product variant when loading data aria-invalid="false" class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id MuiInputBase-inputAdornedEnd-id MuiOutlinedInput-inputAdornedEnd-id" disabled="" - name="priceOverride" + name="price" type="number" value="" /> @@ -110212,7 +109909,7 @@ exports[`Storyshots Views / Products / Create product variant with errors 1`] = @@ -129831,7 +129528,7 @@ exports[`Storyshots Views / Products / Product variant details attribute errors @@ -130723,7 +130420,7 @@ exports[`Storyshots Views / Products / Product variant details when loaded data @@ -131396,7 +131093,7 @@ exports[`Storyshots Views / Products / Product variant details when loading data aria-invalid="false" class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id MuiInputBase-inputAdornedEnd-id MuiOutlinedInput-inputAdornedEnd-id" disabled="" - name="priceOverride" + name="price" type="number" value="" />