Skip to content

Pricing API

The pricing API is used to retrieve the prices of products from Abacus and display them in the Shopware frontend in real time.

Backup price: When creating a product in Shopware, either through the full product sync, through a PIM integration or manually, a product price is required. We recommend using a default price in Shopware, which is then overwritten by the pricing API when the product is displayed in the storefront. In the unlikely event that the pricing API is not available, the default price will be used. This ensures that the product can still be displayed correctly in the storefront, even if the pricing API is not available.

Pricing API Shopware configuration

To configure the pricing API, go to the Shopware administration and open the Abacus integration plugin configuration.
Pricing API configuration

Two options are available:

  • Enable it for not logged in users: This will enable the pricing API for all users that are not logged in.
  • Enable it for logged in users: This will enable the pricing API for logged in users

For the logged in users, we are using the abacus debtor number to identify the user which is saved in the custom fields of the customer entity.

Pricing API Abacus configuration

To have guests retrieving prices from Abacus, you need to configure it in the Abacus application settings (621). Abacus configuration

If guest should get prices from a specific customer, you can set the debtor number in the field "Customer number".

Rounding and decimal precision

To prevent inconsistencies between Shopware and Abacus price calculations, we recommend the following settings:

Shopware settings:

  • Set decimal precision to 9 decimals
  • Disable rounding on position level
  • Round only the grand total to 2 decimals and to 0.05 intervals

Abacus rounding settings

Frontend display: While you might want to display only 2 decimals in the frontend for better readability, it's crucial to work with 9 decimal precision in the background. This ensures that price calculations remain consistent between Shopware and Abacus, especially when dealing with discounts, taxes, and multiple line items.

💡 Why 9 decimals? Working with higher precision prevents rounding errors that can accumulate across multiple calculations and line items, which could otherwise lead to discrepancies between the two systems.

How does it work in the frontend?

When a product is displayed in the storefront, the pricing API is called to retrieve the prices of the product. We hook into categories and product detail pages to display the prices in the storefront as well as in the cart due to price calculation that can be done in abacus on cart level.

💡 Caching: We recommend to use a dedicated Redis instance for caching shopware in general. We also cache the pricing API results in Redis to improve performance. Prices are cached for 60 minutes for logged in and non-logged in users.

Price cache warmup for guest customers

To ensure optimal performance for not logged in customers, we automatically warm up the cache for product prices every hour. This is done through a scheduled background job: