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:

  • Hide pricing for logged-out users
  • Disable add-to-cart for logged out users, or specific price groups (useful for showing add-to-cart only for wholesale customers for example)
  • Change menu items based on whether a customer is logged in or not

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 Maropost Commerce Cloud 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:

  • Hide product prices for logged out customers
  • Hide product RRP's for everyone except for wholesale customers

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.

Step 1 — Setup your Price Groups

We will be using Price/User Groups distinguish between our three different customer types: guests, members and wholesalers.

Price groups are configured by navigating to Settings & Tools > All Settings & Tools and selecting Customer 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 C Wholesalers.

Now, under Settings & Tools > All Settings & Tools in the Customer Settings, we need to set our default price group for different customer types.

Step 2 — Template Logic

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">
p>

To hide the RRP's from everyone but wholesale customers (price group C / 3) we need similar logic:

<div class="savings-container">
div>

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!)

Notes

Was this article useful?

Be notified when this page is updated. Optional.