Skip to content

Commit

Permalink
Fixed: handled when variantId not available in current variants (#85z…
Browse files Browse the repository at this point in the history
…t0m4qc)
  • Loading branch information
adityasharma7 committed Jun 23, 2023
1 parent 7a427e1 commit 9437ab1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"Select item": "Select item",
"Select store": "Select store",
"Selected variant not available": "Selected variant not available",
"Selected variant not available. Reseting to first variant.": "Selected variant not available. Reseting to first variant.",
"Select a new promise date for these orders. This new date will be used for allocating inventory and fulfilling these orders.": "Select a new promise date for these orders. This new date will be used for allocating inventory and fulfilling these orders.",
"Select time zone": "Select time zone",
"Service has been scheduled": "Service has been scheduled",
Expand Down
15 changes: 12 additions & 3 deletions src/views/catalog-product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,18 @@ export default defineComponent({
Object.keys(features).forEach((color) => this.features[color] = sortSizes(features[color]))
const openedVariant = this.product.variants.find((variant: any) => variant.productId === this.$route.params.variantId)
this.selectedColor = getFeature(openedVariant.featureHierarchy, '1/COLOR/')
this.selectedSize = getFeature(openedVariant.featureHierarchy, '1/SIZE/')
let selectedVariant = this.product.variants.find((variant: any) => variant.productId === this.$route.params.variantId)
if (!selectedVariant) {
// if the variant does not have color or size as features
selectedVariant = this.product.variants[0]
showToast(translate("Selected variant not available. Reseting to first variant."))
}
if (selectedVariant) {
this.selectedColor = getFeature(selectedVariant.featureHierarchy, '1/COLOR/')
this.selectedSize = getFeature(selectedVariant.featureHierarchy, '1/SIZE/')
}
},
async updateVariant() {
let variant
Expand Down

0 comments on commit 9437ab1

Please sign in to comment.