This is a brief tutorial to outline how to hide/show information based on a customers user group. This is the best-practice way to:
It's worth noting that while common sense would tell you it's best to check if a customer has a username or not, to tell if they are logged in, this is not the case. The Neto Web Accelerator does not respect usernames but it does respect user-groups—meaning if you can use user groups for this purpose you should as you don't need to use AJAX at all.
For the purpose of the tutorial we will:
Even if this tutorial does not specifically cover the exact customisation you are trying to make, it should be enough to illustrate the best-practice way to implement this kind of customisation.
We will be using Price/User Groups distinguish between our three different customer types: guests, members and wholesalers.
Price groups are configured under
Customisable Fields >
Customer Price Groups. All you need to do in here is rename the price groups you wish to use, so they make more sense.
Let's name Pricegroup A Guests, Pricegroup B Customers and Pricegroup A Wholesalers.
System Setup >
Customer Settings we need to set our default pricegroup for different customer types.
Hiding product prices for logged out customers and product RRP's for everyone except for wholesale customers is now just a matter of using some template logic.
Firstly, to hide the product prices for logged out customers, we just need to wrap the pricing in the following logic:
|<p class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">|
|[%if [@user:group_id@] ne '1'%]|
|[%if [@has_child@]%]from [%/if%]|
|<span itemprop="price">[%format type:'currency'%][@promo_price@][%/format%]</span>|
|<span itemprop="price">[%format type:'currency'%][@store_price@][%/format%]</span>|
|<meta itemprop="priceCurrency" content="[@config:defaultcurrency@]">|
To hide the RRP's from everyone but wholesale customers (price group
3) we need similar logic:
|[%if [@user:group_id@] eq '3'%]|
|<span class="label label-danger">On Sale</span>|
|[%if [@save@] > 0 and ![@has_child@] %]|
|<span class="label label-warning">|
|[%format type:'percent'%][@save@][%/format%] OFF</span>|
|[%if [@save@] > 0%]|
|<span class="label label-default">RRP [%format type:'currency'%][@retail@][%/format%]</span>|
Note that you will need to make the changes above to all thumbnail and product page templates (maybe even the cart and print docs too, if that's what you need!)