Fix no product error on unconfirmed order lines (#2324)

* Fix no product error onunconfirmed order lines

* Update changelog with fix no product error
This commit is contained in:
Dawid 2022-09-22 11:03:21 +02:00 committed by GitHub
parent 88a0db22e1
commit 61fe80bb7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 7 deletions

View file

@ -7,6 +7,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Pass query params in `ORDER_DETAILS_MORE_ACTIONS` and `PRODUCT_DETAILS_MORE_ACTIONS` mounting points - #2100 by @witoszekdev - Pass query params in `ORDER_DETAILS_MORE_ACTIONS` and `PRODUCT_DETAILS_MORE_ACTIONS` mounting points - #2100 by @witoszekdev
- Add product variant reference attribute - #2268 by @droniu - Add product variant reference attribute - #2268 by @droniu
- Fix exit form dialog false positive - #2311 by @orzechdev - Fix exit form dialog false positive - #2311 by @orzechdev
- Fix no product error on unconfirmed order lines - #2324 by @orzechdev
## 3.4 ## 3.4

View file

@ -6567,6 +6567,10 @@
"context": "gift card history message", "context": "gift card history message",
"string": "Gift card was activated" "string": "Gift card was activated"
}, },
"pEMxyy": {
"context": "alert message",
"string": "This product does no longer exist."
},
"pFVX6g": { "pFVX6g": {
"string": "Variant with these attributes already exists" "string": "Variant with these attributes already exists"
}, },

View file

@ -11,4 +11,9 @@ export const lineAlertMessages = defineMessages({
defaultMessage: "This product is not available for sale in this channel.", defaultMessage: "This product is not available for sale in this channel.",
description: "alert message", description: "alert message",
}, },
notExists: {
id: "pEMxyy",
defaultMessage: "This product does no longer exist.",
description: "alert message",
},
}); });

View file

@ -14,18 +14,21 @@ const useLineAlerts = ({ line, error }: UseLineAlertsOpts) => {
const intl = useIntl(); const intl = useIntl();
const alerts = useMemo(() => { const alerts = useMemo(() => {
const {
variant: {
product: { isAvailableForPurchase },
},
} = line;
const alerts: string[] = []; const alerts: string[] = [];
if (error) { if (error) {
alerts.push(getOrderErrorMessage(error, intl)); alerts.push(getOrderErrorMessage(error, intl));
} }
if (!isAvailableForPurchase) {
const product = line.variant?.product;
if (!product) {
alerts.push(intl.formatMessage(lineAlertMessages.notExists));
}
const isAvailableForPurchase = product?.isAvailableForPurchase;
if (product && !isAvailableForPurchase) {
alerts.push(intl.formatMessage(lineAlertMessages.notAvailable)); alerts.push(intl.formatMessage(lineAlertMessages.notAvailable));
} }