logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
SteveFeher  
#1 Posted : Thursday, November 11, 2021 1:10:08 PM(UTC)
SteveFeher

Rank: Member

Groups: Developers, HelpDesk, Registered
Joined: 11/1/2018(UTC)
Posts: 29

Trying to update the Store Header Navigation and show a link to a content page IF a user is a member of a specific group.

For example, if a member is in the "Staff" group, show the link.

The view has the following:

Code:

   @if (user.IsAdmin)
        { 
            (SHOW SOME CODE)
        }



Not sure what the code would be to specify a member of a group. How can we display based on membership in a specific group?

Code:

   @if (user.IsMember) 
      {
             (Show alternate code)
      }



There does not appear to be any previous posts about this kind of topic. Help is appreciated!


Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

mazhar  
#2 Posted : Friday, November 12, 2021 4:28:11 AM(UTC)
mazhar

Rank: Administration

Groups: Admin, Administrators, HelpDesk, System, Authorized User, Developers, Registered
Joined: 10/5/2018(UTC)
Posts: 175

Thanks: 8 times
Was thanked: 17 time(s) in 15 post(s)
If you know your group ID, then you can use something like this
Code:

@if (user.IsInGroup(1))
        { 
            (SHOW SOME CODE)
        }

where 1 needs to be replaced with group id of your group. You can found the group id through admin, visit People > User Groups page. Click the users count against the group name and copy the id from URL.
SteveFeher  
#3 Posted : Friday, November 12, 2021 12:50:38 PM(UTC)
SteveFeher

Rank: Member

Groups: Developers, HelpDesk, Registered
Joined: 11/1/2018(UTC)
Posts: 29

Thanks Mazhar,

The next concern:
In the BuyProductDialog content, I want to show members of my "Staff" group the option to view COGS under the Price.

We used to be able to refer to COGS as a data point, but I don't see this in the code.

Ideally, I'd like to have the following:

Code:

  @if (user.IsInGroup(XX)) 
   {
     <li><span>@GetResourceString("retail.buyproductdialog.cost")</span><span>@Model.Product.Cost</span></li>
   }


Is there a data point for referencing the COGS in the product?
shaharyar  
#4 Posted : Monday, November 15, 2021 3:33:47 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
There is no property for COGs in the BuyProductDialog view model. You will need to update the controller code to add this field value in the view model class.

Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.