B2bContextTrait

What are PHP Traits?

Since PHP 5.4.0, there is a method of reusing code in PHP called traits. Traits is a mechanism for reusing code that is used in programming languages with simple inheritance such as PHP.

Why is the B2bContextTrait useful for your individual extension?

With the B2bContextTrait you can make in your PHP Code a simple function to distinguish the customer ("Customers"). Is the logged-in customer an end customer, an employee/user of a customer or is he a sales employee, you can also query whether the sales employee is currently logged into an end customer.

What are the possible functions:

Note (Alert):

You must always hand over the SalesChannelContext as a parameter.

How can you use our B2bContextTrait in your Shopware extension?

With the "use" function you can add the trait to any PHP class...

And then call the classes from the trait via $this->[function-name].