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.

Allow rendering only one Captcha on the product page

KrzysztofPajakb8e319f94df7
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
index 397389d33..769fe9cc4 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
@@ -393,7 +393,10 @@ namespace Grand.Web.Features.Handlers.Products
NotReturnable = product.NotReturnable,
EmailAFriendEnabled = _catalogSettings.EmailAFriendEnabled,
AskQuestionEnabled = _catalogSettings.AskQuestionEnabled,
- AskQuestionOnProduct = _catalogSettings.AskQuestionOnProduct
+ AskQuestionOnProduct = _catalogSettings.AskQuestionOnProduct,
+ RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnEmailProductToFriendPage
+ || _captchaSettings.ShowOnProductReviewPage
+ || _captchaSettings.ShowOnAskQuestionPage)
};
//automatically generate product description?
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
index d2df41ba9..9637e8a66 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
@@ -103,6 +103,7 @@ namespace Grand.Web.Models.Catalog
public DateTime? EndTime { get; set; }
public DateTime? EndTimeLocalTime { get; set; }
public bool AuctionEnded { get; set; }
+ public bool RenderCaptcha { get; set; }
#region Nested Classes
public partial class ProductBreadcrumbModel : BaseModel
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
index 4f13f2839..e60d39b75 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
@@ -97,7 +97,7 @@
<partial name="_Codes" model="Model" />
<!--delivery-->
@if ((Model.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(Model.DeliveryDate)
- || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
+ || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
{
<partial name="_DeliveryInfo" model="Model" />
}
@@ -236,7 +236,11 @@
<vc:related-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:related-products>
<vc:similar-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:similar-products>
<vc:recommended-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:recommended-products>
- </div>
+ @if (Model.RenderCaptcha)
+ {
+ <partial name="_Captcha" />
+ }
+ </div>
</form>
</validation-observer>
<vc:widget widget-zone="productdetails_bottom" additional-data="@Model.Id"></vc:widget>
diff --git a/src/Web/Grand.Web/Views/Product/_Captcha.cshtml b/src/Web/Grand.Web/Views/Product/_Captcha.cshtml
new file mode 100644
index 000000000..a27265bf0
--- /dev/null
+++ b/src/Web/Grand.Web/Views/Product/_Captcha.cshtml
@@ -0,0 +1,5 @@
+<div id="captcha-container">
+ <div class="captcha-box" id="captcha-box">
+ <captcha />
+ </div>
+</div>
\ No newline at end of file