B2B for SAP Commerce Cloud
Learn how to add B2B features to your SAP Commerce Cloud Storefront.
SAP Commerce Cloud exposes different endpoints for B2C, and B2B logic, such as adding an item to the cart. By default the Alokai Storefront ships with the B2C implementation of the Unified Methods. To add B2B features to your SAP Commerce Cloud Storefront, you need to overwrite the default methods with the B2B methods in your middleware configuration.
Configuration
The @vsf-enterprise/unified-api-sapcc
package contains already the @vsf-enterprise/unified-api-sapcc/b2b
subpath export which contains the Unified Methods implementation for B2B.
In the apps/storefront-middleware/middleware.config.ts
file:
- Import the
b2b
methods
import { apiMethods as b2bApiMethods } from '@vsf-enterprise/unified-api-sapcc/b2b';
- Extend the
unifiedApiExtension
methods with theb2bApiMethods
property.
export const unifiedApiExtension = createUnifiedExtension<Context>()({
normalizers,
apiMethods: {
...methods<typeof normalizers>(),
...b2bApiMethods<typeof normalizers>();
}
});
As some of the SAP Commerce Cloud API endpoints are the same for B2C and B2B, the b2bApiMethods
will override only the implementation for:
getCustomer
loginCustomer
updateCustomer
addCartLineItem
updateCartLineItem
As the B2B methods implement the same contract of the Unified Methods as B2C methods, there is no need to change the Storefront code.
Modules
To find out more, how to add additional features to the SAP Commerce Cloud B2B Storefront, check the modules.