Show product descriprion only to specific customer role.

Posted: August 24, 2019 at 8:54 AM Quote #245179
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.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: August 24, 2019 at 9:07 AM Quote #245180
Hello Zaf,

You can do that using a plugin if you are going to use nopCommerce plugin architecture or if you are customizing source code, it will be more easier.

In both cases, you need to add a new permission record for example "Public store.Display product full description" and then modify product template CSHTML file to use this permission where exactly you want to place it. Once done, you just need to configure this newly added permission record for any customer role that you wanted.

I hope this will help you to solve your problem. There is no other way to do this beside what I told you above.

Thank you,
Atul
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Need any professional assistance? Drop us your requirements on [email protected] or Skype @ live:nopadvance.sales

https://nopadvance.com
nopCommerce Solution Partner
Posted: August 26, 2019 at 2:14 AM Quote #245245
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.
This post/answer is useful
2
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
www.Nop-Templates.com - the best place for nopCommerce themes and plugins

Follow us on
Facebook: http://www.facebook.com/NopTemplates
Twitter: http://twitter.com/NopTemplates
Blog: http://www.nop-templates.com/blog

www.Nop-Templates.com
nopCommerce Solution Partners
Posted: August 26, 2019 at 2:16 AM Quote #245246
Nop-Templates.com 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 butyou 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 == "[b]Cookies") != null[/b])
                    {
                        <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.


Perfect..

Regards,
Atul
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Need any professional assistance? Drop us your requirements on [email protected] or Skype @ live:nopadvance.sales

https://nopadvance.com
nopCommerce Solution Partner
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.