zaf wrote:Hi.
I want to use nopCommerce for selling video lessons content.
What I need is to show products and short description with demo, but do not show full description. In full description there would be paid content.
So, full descripion would be allowed only for specific customer role.
css display:none DOES NOT WORK FOR US.
Any ideas about how to do it?
Thanks for help in advance.
Hello
zaf,
it is not a good practise but you achieve this by editing your
ProductTemaplate.Simple.cshtml file.
You need to add the
@inject Nop.Core.IWorkContext workContext on top like so:
@model ProductDetailsModel
@using Nop.Core.Domain.Seo;
@inject Nop.Core.IWebHelper webHelper
@inject SeoSettings seoSettings
@inject Nop.Core.IWorkContext workContext
Then you need to find the
IF statement around your
full-description and extend it like so:
@if (!string.IsNullOrEmpty(Model.FullDescription) && workContext.CurrentCustomer.CustomerRoles.FirstOrDefault(cr => cr.SystemName == Nop.Core.Domain.Customers.NopCustomerDefaults.RegisteredRoleName) != null)
{
<div class="full-description" itemprop="description">
@Html.Raw(Model.FullDescription)
</div>
}
This would work if you are using any of the Default Customer Roles, you just need to edit the last part to fit the exact role you want the content to show to.
However, if you want to add a totally new Customer role, you can then use the following
IF statement instead:
@if (!string.IsNullOrEmpty(Model.FullDescription) && workContext.CurrentCustomer.CustomerRoles.FirstOrDefault(cr => cr.SystemName == "Cookies") != null)
{
<div class="full-description" itemprop="description">
@Html.Raw(Model.FullDescription)
</div>
}
Just instead of
Cookies, use the
System name for your new
Customer role.
Hope this was helpful.
Best Regards,
Valentin.