Всего сообщений:
18
Карма:
108
Присоединился:
08.12.2011
Страна:
India
Hi All, How to check in nopCommerce2.30 customer role. With Regards Murali
Всего сообщений:
6
Карма:
30
Присоединился:
22.08.2012
Страна:
United States
hi i tried using this code in _ColumnsOne.cshtml and got an error CS0103: The name 'customer' does not exist in the current context do i need to put additional code in before i can use it? im using nop v 2.6
Всего сообщений:
11347
Карма:
101167
Присоединился:
22.05.2011
Страна:
United States
That code won't work in .cshtml files (Views). Do you have Visual Studio 2010? Do you know MVC?
Всего сообщений:
6
Карма:
30
Присоединился:
22.08.2012
Страна:
United States
ah i see, i am a front end developer so i know a little mvc concept but i do not have visual studio
Всего сообщений:
11347
Карма:
101167
Присоединился:
22.05.2011
Страна:
United States
The right way (MVC) to do this is in a Controller. But here's a hack you can put at the top of the View (.cshtml file) @using Nop.Services.Customers; @{ bool customerHasRoleX = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("X"); } You can then reference the customerHasRoleX variable - you will need to reference it as @customerHasRoleX, if you are not within the scope of another @{ ...} block
Всего сообщений:
34
Карма:
186
Присоединился:
22.09.2010
Страна:
United States
I have verion 2.8. and get error The type or namespace name 'IWorkContext' could not be found (are you missing a using directive or an assembly reference? I put in the reference @using Nop.Services.Customers, as well
Всего сообщений:
11347
Карма:
101167
Присоединился:
22.05.2011
Страна:
United States
try adding @using Nop.Core
Всего сообщений:
34
Карма:
186
Присоединился:
22.09.2010
Страна:
United States
Thank you that did it!! Nothing like a break after searching for a week!
Всего сообщений:
26
Карма:
170
Присоединился:
16.09.2010
Страна:
United States
At the top of the cshtml, I needed: @using Nop.Core; @using Nop.Core.Domain.Customers; @using Nop.Core.Infrastructure; @using Nop.Services.Customers; Then in the page I added: @if (EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("xx")) { //my stuff } Works great, thanks!