Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Fix - Bug when we have discount and product attributes #357

support073bb855c887
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
index da3b7de44..0a6bb1eb7 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
@@ -12,7 +12,9 @@
<div class="product-price call-for-price col-12 px-0">
<b-button v-b-modal.modal-1>@Loc["Products.CallForPrice"]</b-button>
<b-modal id="modal-1" hide-footer title="@Loc["Products.CallForPrice"]">
- <p class="my-4"><span>@Loc["Products.CallForPrice"]:</span><a href="tel:@workContext.CurrentStore.CompanyPhoneNumber"> @workContext.CurrentStore.CompanyPhoneNumber</a></p>
+ <p class="my-4">
+ <span>@Loc["Products.CallForPrice"]:</span><a href="tel:@workContext.CurrentStore.CompanyPhoneNumber"> @workContext.CurrentStore.CompanyPhoneNumber</a>
+ </p>
</b-modal>
</div>
}
@@ -49,25 +51,17 @@
}
if (!(Model.IsAuction && Model.DisableBuyButton))
{
- <div class="@if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
- {<text>product-price col-12 px-0 d-inline-flex align-items-center</text>}
- else
- {<text>non-discounted-price col-12 px-0 d-flex align-items-center</text>}">
+ <div class="@if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount)) {<text>product-price col-12 px-0 d-inline-flex align-items-center</text>} else {<text>non-discounted-price col-12 px-0 d-flex align-items-center</text>}">
<span class="price-value-@(Model.ProductId) @if (string.IsNullOrEmpty(Model.PriceWithDiscount)) {<text>actual-price</text>}">
- @if (Model.IsAuction)
- {
- <strong class="actual-price">@Loc["Products.BuyNowPrice"]:</strong>
- }
-
- @if (string.IsNullOrEmpty(Model.PriceWithDiscount))
- {
- <span class="actual-price">@Html.Raw(Model.Price)</span>
- }
- else
+ <strong>@Html.Raw(Model.Price)</strong>
+ @if (!string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
{
- <strong>@Html.Raw(Model.Price)</strong>
+ <div class="d-inline-flex align-items-center product-price discounted-price col-12 px-0">
+ <label class="mb-0 mx-2">@Loc["Products.Price.WithDiscount"]:</label>
+ <strong class="actual-price">@Html.Raw(Model.PriceWithDiscount)</strong>
+ </div>
}
-
+ <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" class="your-price price-value-@(Model.ProductId)"/>
</span>
@if (!string.IsNullOrWhiteSpace(Model.OldPrice))
{
@@ -87,17 +81,6 @@
</div>
}
}
-
- if (!string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
- {
- <div class="d-inline-flex align-items-center product-price discounted-price col-12 px-0">
- <label class="mb-0 mx-2">@Loc["Products.Price.WithDiscount"]:</label>
- <span class="your-price price-value-@(Model.ProductId)">
- <strong class="actual-price">@Html.Raw(Model.PriceWithDiscount)</strong>
- </span>
- <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" class="your-price price-value-@(Model.ProductId)" />
- </div>
- }
if (!string.IsNullOrEmpty(Model.BasePricePAngV))
{
<div class="base-price-pangv ml-2">
@@ -106,11 +89,11 @@
}
if (!string.IsNullOrEmpty(Model.CurrencyCode))
{
- <meta itemprop="priceCurrency" content="@Model.CurrencyCode" />
+ <meta itemprop="priceCurrency" content="@Model.CurrencyCode"/>
}
@if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
{
- <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" />
+ <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)"/>
}
}
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
index ebae28709..f4611a2bc 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
@@ -229,7 +229,10 @@
params: { product: '@Model.Id' },
}).then(function (response) {
if (response.data.price) {
- document.querySelector('[email protected]').innerText = response.data.price;
+ if (document.querySelector('[email protected] .actual-price'))
+ document.querySelector('[email protected] .actual-price').innerText = response.data.price;
+ else
+ document.querySelector('[email protected]').innerText = response.data.price;
}
if (response.data.sku) {
if(document.querySelector('#[email protected]'))
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Prices.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Prices.cshtml
index 02bec9b0a..aeeed14f2 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Prices.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Prices.cshtml
@@ -35,17 +35,17 @@
<span class="h6 mb-0">{{PopupQuickViewVueModal.ProductPrice.CatalogPrice}}</span>
</div>
</template>
- <template v-if="!(PopupQuickViewVueModal.ProductPrice.IsAuction && PopupQuickViewVueModal.ProductPrice.DisableBuyButton)">
+ <template v-if="!(PopupQuickViewVueModal.ProductPrice.DisableBuyButton)">
<div v-bind:class="{ 'product-price col-12 px-0 d-inline-flex align-items-center': (PopupQuickViewVueModal.ProductPrice.PriceWithDiscount !== null), 'non-discounted-price col-12 px-0 d-flex align-items-center': (PopupQuickViewVueModal.ProductPrice.PriceWithDiscount == null) }">
- <span :class="'price-value-' + PopupQuickViewVueModal.ProductPrice.ProductId">
- <template v-if="PopupQuickViewVueModal.ProductPrice.IsAuction">
- <strong class="actual-price bid">@Loc["Products.BuyNowPrice"]:</strong>
- </template>
- <template v-if="PopupQuickViewVueModal.ProductPrice.PriceWithDiscount == null">
- <span class="actual-price" v-html="PopupQuickViewVueModal.ProductPrice.Price"></span>
- </template>
- <template v-else>
- <strong>{{PopupQuickViewVueModal.ProductPrice.Price}}</strong>
+ <span :class="['price-value-' + PopupQuickViewVueModal.ProductPrice.ProductId, {'actual-price': (PopupQuickViewVueModal.ProductPrice.PriceWithDiscount == null) }]">
+ <strong>{{PopupQuickViewVueModal.ProductPrice.Price}}</strong>
+ <template v-if="PopupQuickViewVueModal.ProductPrice.PriceWithDiscount != null">
+ <div class="d-inline-flex align-items-center product-price discounted-price col-12 px-0">
+ <label class="mb-0 mx-2">@Loc["Products.Price.WithDiscount"]:</label>
+ <span :class="'your-price price-value-' + PopupQuickViewVueModal.ProductPrice.ProductId">
+ <strong class="actual-price" v-html="PopupQuickViewVueModal.ProductPrice.PriceWithDiscount"></strong>
+ </span>
+ </div>
</template>
</span>
<template v-if="PopupQuickViewVueModal.ProductPrice.OldPrice !== null">
@@ -62,15 +62,6 @@
</div>
</template>
</template>
- <template v-if="PopupQuickViewVueModal.ProductPrice.PriceWithDiscount !== null">
- <div class="d-inline-flex align-items-center product-price discounted-price col-12 px-0">
- <label class="mb-0 mx-2">@Loc["Products.Price.WithDiscount"]:</label>
- <span :class="'your-price price-value-' + PopupQuickViewVueModal.ProductPrice.ProductId">
- <strong class="actual-price" v-html="PopupQuickViewVueModal.ProductPrice.PriceWithDiscount"></strong>
- </span>
- <meta itemprop="price" content="PopupQuickViewVueModal.ProductPrice.PriceValue" :class="'your-price price-value-' + PopupQuickViewVueModal.ProductId" />
- </div>
- </template>
<template v-if="PopupQuickViewVueModal.ProductPrice.BasePricePAngV !== null">
<div class="base-price-pangv ml-2">
{{PopupQuickViewVueModal.ProductPrice.BasePricePAngV}}
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index 9b0e651aa..e4e8fb6c2 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -396,7 +396,10 @@ var vm = new Vue({
} else {
if (response.data.price) {
if (vm.PopupQuickViewVueModal.ProductType == 0) {
- vm.PopupQuickViewVueModal.ProductPrice.Price = response.data.price;
+ if(vm.PopupQuickViewVueModal.ProductPrice.PriceWithDiscount!=null)
+ vm.PopupQuickViewVueModal.ProductPrice.PriceWithDiscount = response.data.price;
+ else
+ vm.PopupQuickViewVueModal.ProductPrice.Price = response.data.price;
} else {
vm.PopupQuickViewVueModal.AssociatedProducts.find(x => x.Id === pId).ProductPrice.Price = response.data.price;
}