# B2bPlatformContext

## **What is the B2bPlatformContext?**

In the Shopware standard there is already the normal SalesChannelContext, we have extended this via the "extension" accordingly with a new b2BPlatformContext to provide B2B-specific data in the user context.

#### Examples:

* Which employee of a "customer" is logged in?
* Is a sales employee logged in? And is he currently logged in to a customer.
* Is the employee an admin or not?
* Which employee with which role is logged in?

The b2bPlatformContext is available from anywhere. (Can be accessed from anywhere.)

#### **Example:**

![Figure 1. This B2BPlatform Context shows that the user is an employee of a client (isEmployee: true).](https://content.gitbook.com/content/ZeoybxBUcYCMKmpQgzFq/blobs/pIJxLZy03iyELr7nKLPW/example%20-%20B2BPlatformContext.png)

<div align="left"><img src="https://content.gitbook.com/content/ZeoybxBUcYCMKmpQgzFq/blobs/GEyENnznOPcFZGujEppj/example%20-%20B2BPlatformContext%202.png" alt="Figure 2 - This B2bPlatformContext shows a loggedin sales representative who has not yet logged in to a customer employee."></div>

#### **Note alert**

the B2BplatformContext is only set when you are logged in as, so we always recommend asking beforehand.

```
if(!$context->hasExtension('b2bPlatformContext')) {
return; 
}
```

Alternatively, the B2BPlatformContext can always be requested via the B2bContextTrait (see documentation [b2bcontexttrait](https://docs.b2b-sellers.com/b2b-platform/2/developer-guides/b2bsellers-core-plugin/b2bcontexttrait "mention")).

![](https://content.gitbook.com/content/ZeoybxBUcYCMKmpQgzFq/blobs/U1PR4brKRkWQ2euw0SQs/example%20-%20B2BPlatformContext%203.png)

#### Note Alert:

In the employeeCustomer is the connection table between the logged-in employee and the assigned customer. The role, admin, etc. are maintained here.

#### Examples:

<div align="left"><img src="https://content.gitbook.com/content/ZeoybxBUcYCMKmpQgzFq/blobs/PMoHlwYvGOcCUMEfJxpm/example%20-%20B2BPlatformContext%204.png" alt="Figure 3. Here will be checked whether the logged-in user is a sales employee."></div>

![Figure 4: Here, the logged-in employee will be queried via the B2bPlatformContext. Notice. These are the general employee data, not the employees ->mapping -> Customer data.](https://content.gitbook.com/content/ZeoybxBUcYCMKmpQgzFq/blobs/YG5Qtjci5fmolI8sfCmi/example%20-%20B2BPlatformContext%205.png)
