Calculation of the shopping cart

Introduction

The heart of a store is the shopping cart. A comprehensible and correct calculation of the sums, items and VAT is essential to not disturb the confidence of customers in the store. For this reason, this article should clarify the calculation basis of the shopping cart and give you options to check the calculation yourself. In addition to numerous basic functions of Shopware such as extended prices, shipping costs, coupons and discounts, there are of course also countless extensions that hook into the calculation of the shopping cart. Thus, it is important that you also get an idea of which extensions may influence the calculation and what effects this may have.
 

Basics

In most countrys, there are two valid methods for calculating VAT. The horizontal (line-by-line) and the vertical (column-by-column) method. In the horizontal method, the VAT is calculated per shopping cart item. The VAT percentages of each shopping cart item are displayed during the order completion process. The VAT total is then calculated from the VAT portions of the individual items.
In contrast, in the vertical procedure, the VAT total is calculated on the basis of the total order amount. The VAT portions of the individual items are not displayed in the order closing.

Shopware also shows two decimal places at all points on the storefront. So that your customers can always understand the calculation, it is also always calculated with the value rounded to 2 digits.

Calculation examples

  • Row by row (horizontal) calculation
    Net
    QuantityVAT-SetNetGrossNet totalplus VATGross total
    571,49-5*1,497,45*0,077,45+0,52
        7,450,527,97

    Gross
    QuantityVAT-SetNetGrossNet totalplus VATGross total
    57-1,597,95/1,077,95-7,435*1,59
        7,430,527,95
  • Column by column (vertical) calculation
    Net
    QuantityVAT-SetNetGrossplus VATNet-totalplus VATGross total
    571,491,590,105*1,495*0,107,45+0,50
         7,450,507,95

    Gross
    QuantityVAT-SetNetGrosscont. VATNet-totalcont. VATGross total
    571,491,590,107,95-0,505*0,105*1,59
         7,450,507,95

Explanation

The calculation differences arise here on the basis of the calculation method used. In online stores, the vertical calculation is by all means the more common one, as it is important to many store operators to be able to show the VAT included at item level. This would not be possible with the horizontal calculation, as the rounded item values can never add up to the total value.

Debugging

Shopware does not have a central place to calculate the shopping cart. The calculations in the front- and backend are basically separated from each other. Therefore, you should always follow the complete path in your store if you suspect an error here. The best thing to do when a customer contacts you is as follows:

  • Reconstruct shopping cart in storefront
  • Take a screenshot of the order completion page (/checkout/finish)
  • Compare totals in the order overview with the screenshot
  • Compare totals in PDF invoice with screenshot
  • Check calculated shopping cart with Excel spreadsheet

If a problem is confirmed here, you should first check whether one of the extensions used interferes with the calculation of the shopping cart. To do this, you can set up a test environment that does not contain any extensions.

Was this article helpful?