Customer-specific Pricing
The Customer-specific pricing feature enables significant advances in pricing model capabilities in the Shopware 6 ecosystem.
The API interface exposed by this module allows the user to execute a set of commands that enable granular price overrides via an external data repository or ERP system. This is achieved by defining a custom relationship between the current price and the Customer entity.
Pre-requisites and setup
Customer-specific pricing is part of the Commercial plugin and requires an existing Shopware 6 installation and the activated Shopware 6 Commercial plugin. This Commercial plugin can be installed as per the install instructions. In addition, the Custom Prices feature needs to be activated within the relevant merchant account.
Working with the API route
To create, alter, and/or delete customer-specific prices, you can use the API endpoint /api/_action/custom-price. Like with any other admin request in Shopware, you must first authenticate yourself. Therefore, please head over to the authentication guide for details.
Otherwise, the Customer-specific Pricing API interface models itself on the sync API, so you can package your requests similarly.
INFO
You can use the route with a single upsert and delete action, or combine them in a single request: you can pack several different commands into a single sync API request, and each is executed in an independent, isolated way.
So, it's not surprising that the request body looks like a familiar sync request. In the payload for the upsert action, you pass the following data:
productId: The product whose price should be overwritten.customerId: The customer for whom we will assign a custom price.price: The new custom price you want to use.
This way, we come to use a payload as seen in the example below:
[
{
"action": "upsert",
"payload": [
{
"productId": "0001e32041ac451386bf9b7351c540f3",
"customerId": "02a3c82b5ca842c492f8656029b2e63e",
"price": [
{
"quantityStart": 1,
"quantityEnd": null,
"price": [
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"gross": 682.0,
"net": 682.0,
"linked": true
}
]
}
]
}
]
}
]For the delete action, the workflow operation accepts 3 different arrays of ids: customerIds, productIds, or customerGroupIds. Here, you can specify any combination of these ID arrays, with the exception that the API route must have at least one UUID supplied in one of the ID arrays (customerIds, productIds, or customerGroupIds)
[
{
"action": "delete",
"payload": [
{
"productIds": [
"0001e32041ac451386bf9b7351c540f3",
"363a6985f6434a7493b1ef3dabeed40f"
],
"customerIds": [
"53fc38877a510a47b0e0c44f1615f0c5"
],
"customerGroupIds": []
}
]
}
]INFO
In case an error occurs, the response will not return an error code, which is typical for the sync API; instead, any validation errors will be stored within the errors key.
WARNING
When working with this route, one difference sets it apart from the familiar sync requests: You cannot specify headers to adapt the endpoint's behavior.
Known caveats or issues
When working with custom prices, there are currently some caveats or issues to keep in mind:
- Price filtering (within the product listing page) will currently not support the overridden prices.
- ElasticSearch product mapping does not currently support Customer-specific Pricing data.
- Optional header flags within the core
syncAPI are not supported within the provided endpoint (indexing-behavior, single-operation). Indexing of any relevant database (product) data is handled on a per-request basis, without the need to specify indexing. - The
customerGroupIdparameter within a Customer-specific Pricing API request body is a stub implementation to avoid breaking changes in future versions and is not currently functional. Any data provided for this parameter will not affect the Storefront.