From 51e11e850a8e1bfdd894311b51b294b7e7e0670b Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 3 Apr 2024 12:36:10 +0530 Subject: [PATCH] Improved: logic to update variantId in url on changing (#166) --- src/views/catalog-product-details.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/views/catalog-product-details.vue b/src/views/catalog-product-details.vue index e91e6075..1a592f73 100644 --- a/src/views/catalog-product-details.vue +++ b/src/views/catalog-product-details.vue @@ -488,7 +488,7 @@ export default defineComponent({ const selectedFeatures = this.selectedFeatures selectedFeatures[feature] = option - const variant = this.product.variants.find((variant: any) => { + let variant = this.product.variants.find((variant: any) => { let isVariantAvailable = true Object.entries(this.selectedFeatures).map((currentFeature) => { if(getFeature(variant.featureHierarchy, `1/${currentFeature[0]}`) != currentFeature[1]){ @@ -513,10 +513,11 @@ export default defineComponent({ }) this.updateSeletedFeatures(availableVariants[0]) - this.currentVariant = availableVariants[0] + variant = availableVariants[0] showToast(translate("Selected variant not available. Reseting to first variant.")) } + this.currentVariant = variant; this.getFeatures() this.updateVariant(); },