# Company Shared Orders and Customer Groups

## Use Case

As a B2B seller, you'd like to set permissions and scopes to your end customers and respond to their specific needs. While the buyer companies have multiple representatives, with frequently different liability levels, it is crucial for them to manage the users and assign relevant permissions to the organization resources in your store. For example, they'd like to keep their purchase orders under control and therefore they'd like to be able to view the orders made not only by themselves but also the other orders that were related to their company (legal entity).

In this case, customer groups and shared orders features come very useful on the storefront. With the right access, the end customers are able to take care of user management on their own, without the need to contact your support team.

## Customer Groups in the Management Dashboard

As a B2B seller, you have an option in the Management Dashboard to create and manage B2B customer groups. Customer groups are legal-entity-aware, so the information relevant to the company can be read by the relevant customer group.

A customer group is automatically created when creating a company in the system. A customer assigned to the legal entity (company) is assigned to the customer group. Also, a new customer that signs up to the storefront, gets assigned to the customer group related to the company they provide during the registration.

To manage a customer group on behalf of your B2B customer in the Management Dashboard, go to the **Customer Management -> Groups**. You can create and edit customer groups from there. You can change and add permission scopes or manage group members.

### Adding company related orders visibility

To allow your customers to view the orders associated with the same organization, assign the `read` scope for legal entity in relation to the order objects.

{% stepper %}
{% step %}
**Go to Groups**

In the Management Dashboard, go to the **Customer Management -> Groups** module.
{% endstep %}

{% step %}
**Go to edit mode**

Edit the chosen group.
{% endstep %}

{% step %}
**Assign permissions**

In the **Customer Settings** section, assign the `read` permission for orders and save the changes.

<figure><img src="/files/9O3QPfllp93tQkPBkE1h" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
The system ensures orders are only shared among users assigned to the same company.\
When a customer belongs to more than one legal entity, the permissions related to the customer groups are resolved with the refresh token. When a customer switches to another legal entity, the token gets refreshed with the relevant `legalEntityId`. This way, the right scopes and permissions are received for the customer in relation to each organization. So, for one legal entity the customer can have the access to the company-related orders while for another legal entity not.
{% endhint %}

## Viewing shared orders on the storefront

Your B2B customer now has an option to monitor what has already been ordered on behalf of their organization.\
After logging in, they go to their account details.

<figure><img src="/files/l7SC2Q3IXjUUz3pDT0Qm" alt="" width="300"><figcaption></figcaption></figure>

In **My Orders**, they can view the orders placed by themselves:

<figure><img src="/files/aWuEC6CbqzjVSd8YsHsC" alt=""><figcaption></figcaption></figure>

But, if they have been assigned to a group with the `read for legal entity` scope for orders, they can also view the history of orders placed by other members of their company:

<figure><img src="/files/zGBBjsRFT6VHzkHbCvIw" alt=""><figcaption></figcaption></figure>

Viewing the orders related to the company improves the collaboration and transparency for your customers as it allows them to check the order details, return the items, or make the same order if needed.

Thanks to the scopes and permissions, they can consciously control who gets access to the company's shared information. If they don't have the right scope assigned, they're not able to see the company-related orders:

<figure><img src="/files/I207KEVgGmCedHzzvVIO" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
To see how B2B customers can manage the users from the same legal entity on their own on the storefront, see the [User Management and Approvals](/ce/customer-use-cases/scenarios-introduction/right-roles.md) use case.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/ce/customer-use-cases/scenarios-introduction/shared-orders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
