Surcharges & discounts

Cart processing

What the plugin does when Shopware recalculates the cart, step by step, as implemented in the source code.

What happens on every recalculation.

  1. Is the plugin active in the sales channel?

    The switch in the plugin configuration applies per sales channel. If it is off, nothing happens.

  2. Is there anything in the cart?

    An empty cart stays empty, even with an always-valid rule.

  3. Does the request come from the administration?

    When an order is created or edited in the admin or through the Admin API, the plugin only keeps the items that are already there. No new ones are added and none are removed.

  4. Which items qualify?

    Active items of this sales channel whose rule currently applies to the customer and the cart and which the customer has not removed in this session. Sorted by the Position field, ties by their ID.

  5. How many?

    One, or the linked quantity, at least one. A percentage always one. With a maximum purchase the quantity is cut to what is left; at zero the item drops out.

  6. What does it cost?

    A percentage on everything in the cart at that moment. A fixed amount times quantity, with its tax rate. A Shopware product with its price or free of charge.

  7. And the next one?

    Every item enters the cart before the next one is calculated. That is why the order determines what a percentage is calculated on.

The trap with the cart total.

The condition "Cart total (incl. shipping)" counts everything, including the surcharge the plugin has just added. If its own rule depends on an upper limit, the surcharge pushes the total above it, the rule no longer applies, the surcharge drops out, the total falls, the rule applies again.

Shopware stops this back and forth after a few passes and keeps the last state, usually without the surcharge. Checked in a test environment: 12 × €20.00 of goods, €25.00 surcharge. With the cart total it disappeared, with the subtotal of goods it stayed.

The subtotal of goods (excl. discounts/fees) only counts goods. Pseudo products do not count there, nor do shipping costs. A Shopware product counts as goods and therefore stays self-referential there too if it has a price.

Rule: cart total is less than €250.00

  1. Goods€230.00
  2. Shipping€7.50
  3. Total without surcharge: rule applies€237.50
  4. Surcharge is added€25.00
  5. Total with surcharge: rule no longer applies€262.50

Worked example. With the subtotal of goods only the goods count, €230.00, and the surcharge stays.

What the shop remembers per session.

Removed items

Which removable items the customer has removed. They do not come back in this session.

Notes shown

Which cart notes with Display Once have already been seen.

Previous orders

The counted quantity for the maximum purchase. It is counted again as soon as the customer account changes, for instance through a new order.

The chapters.