# Catalogs per customer group

URL: https://docs.sparklayer.io/help/storefront/b2b-catalogs/configuring-advanced-catalogs
Applies to: Shopify

Show or hide product variants for particular B2B customer groups with sparklayer.settings metafield rules, the base group and b2b- customer tags in Shopify.

> **Quick summary**
>
> - With catalogs per customer group, some products are only visible to particular B2B [customer groups](https://docs.sparklayer.io/help/glossary.md#customer-group). You show or hide them variant by variant, for each group.
> - You set the rules in the `sparklayer.settings` variant [metafield](https://docs.sparklayer.io/help/glossary.md#metafields), an extra field on each variant in your Shopify admin. A [form on this page](#set-up-variant-visibility) writes the rule for you to copy.
> - You also need the [SparkLayer Wholesale app](https://docs.sparklayer.io/help/platforms/shopify/install.md) for Shopify.
> - Products using these rules must still be tagged `b2b-only`.

## How it works

Every variant is visible to every customer group by default. To hide a variant from a group, you add a rule to the variant's `sparklayer.settings` metafield. The rule names the customer group and sets `display` to `false`. If all of a product's variants are hidden for a customer, they don't see the product at all.

How a variant rule hides a product:

1. **Customer tag**: The customer's tag, such as `b2b-vip`, places them in the `vip` customer group.
2. **Variant rule**: The variant's `sparklayer.settings` rule for `vip`, or for `base`, sets `display` to `true` or `false`.
3. **Product**: If every variant is hidden for the customer, the whole product is hidden.

> **Tag products b2b-only**
>
> Products using customer group metafield rules must still be tagged `b2b-only` for the visibility rules to apply.

For what each method hides, across SparkLayer's views and your theme's pages, see [What hides what](https://docs.sparklayer.io/help/storefront/product-settings.md#what-hides-what).

## Set up variant visibility

1. Create the `sparklayer.settings` variant metafield. See [Product rules per customer group](https://docs.sparklayer.io/help/storefront/product-settings.md#set-product-settings-for-a-customer-group) for how to add it.
2. Tag the product `b2b-only` in your Shopify admin.
3. In the form below, enter each customer group's [name](#find-the-group-name) and choose **Yes** or **No** under **Show the product**. It writes the rule for you.
4. Click **Copy**, open the variant, paste the value into the `sparklayer.settings` metafield and click **Save**.

**Lots of products? Fill them in one table (Shopify):** in your Shopify admin, go to **Products**, tick the products and click **Edit products**. Click **Columns**, tick the SparkLayer field under **Metafields**, type the values and click **Save**. See [Shopify's guide](https://help.shopify.com/en/manual/custom-data/metafields/bulk-edit-metafields).

**More detail**

The metafield accepts a list of rules. Each rule names a customer group and whether the variant is displayed for that group:

```json
[
{
"customer_group": "group-name",
"display": true / false
}
]
```

`display` is one of the [sparklayer.settings product settings](https://docs.sparklayer.io/help/storefront/product-settings.md#available-product-settings), which also cover pack sizes, quantity limits and whether a variant can be added to the cart.

## Find the group name

On Shopify, customers are placed in SparkLayer customer groups with a tag in the format `b2b-[group]`, where `[group]` is the group name. In the metafield, use only the group name, without the `b2b-` prefix. For example, use `vip`, not `b2b-vip`:

| Customer tag in Shopify | Group name in the metafield |
| --- | --- |
| `b2b-vip` | `vip` |
| `b2b-wholesale` | `wholesale` |
| `b2b-trade` | `trade` |

For how customers are matched to groups, see [Customer groups](https://docs.sparklayer.io/help/customers/customer-groups.md).

## Use the base group

The special customer group `base` sets the default visibility for all B2B customers. Use it to hide a product from everyone, then show it to particular groups. For an example, see [Hide a product from all B2B customers except one group](#hide-a-product-from-all-b2b-customers-except-one-group).

Setting `base` to `false` hides the product for all B2B customer groups, even if the product is tagged `b2b-only`. An entry for a specific group overrides `base` for that group, so you can show it to that group again.

If you also set a pack size or a quantity limit, put it in the same `sparklayer.settings` value, inside each group's entry. When a variant has a `sparklayer.settings` value, individual metafields such as `sparklayer.pack_size` are ignored. See [Which rule wins](https://docs.sparklayer.io/help/storefront/product-settings.md#which-rule-wins).

## Examples

These are the common rules. Build your own with the [form](#set-up-variant-visibility), or copy one into the variant's `sparklayer.settings` metafield and change the group name.

### Hide a product from all B2B customers except one group

This variant is hidden from all B2B customers except those in the `vip` customer group (customers tagged `b2b-vip`):

```json
[
  {
    "customer_group": "base",
    "display": false
  },
  {
    "customer_group": "vip",
    "display": true
  }
]
```

### Hide a product from one customer group

This variant stays visible to all B2B customers except those in the `vip` customer group:

```json
[
  {
    "customer_group": "vip",
    "display": false
  }
]
```

## FAQs

**How many variants can a product have?**

We can only guarantee that variants are shown and hidden as expected on products with 250 variants or fewer, because of the way Shopify gives themes access to product variants. See [B2B Catalogs limitations](https://docs.sparklayer.io/help/storefront/b2b-catalogs/limitations.md).
