1

I'm building a webshop with hair care products, certain products however shouldn't be available to all members. We plan to have two member groups, regular buyers and haircare professionals.

So what I need to do is mark certain products to only be available to a specific member group(professionals).

What's the easiest way to achieve this? All the products are currently in one channel and I would prefer to keep them this way.

Should I just make a simple switch fieldtype? Is it possible to just write some type of "if member group = 4 AND fieldtype = yes" statement?

thanks!

1 Answer 1

1

There are a couple of different ways you could go about it, you could indeed use a P&T Switch or P&T Pill field in your channel then have something along the following:

{exp:channel:entries channel="products" limit="100"}
 {if logged_in_member_group == 4 && professionals_switch == "yes"}
  {!-- show Professional items here --}
  {title} -- {price}
 {/if}
 {if professionals_switch == "no"}
  {!-- if you still want to show non-professional items to the professionals you will need to have it here. This will also show only non-professional items to other users --}
  {title} -- {price}
 {/if}
{/exp:channel:entries}

You could also do the same with checking a member group and to see if a category has been set.

This approach should work without a problem if you are not using pagination or outputting the products in an ordered list since EE would actually be grabbing all of the products but only showing a portion based upon the conditionals being true which would have some pages resulting in less content or missing numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.