Photo: free stock photography (Unsplash licence) — see imprint
Why they exist
An app server is remote, and the cart recalculates constantly. Calling out over HTTP on every recalculation would be unusable. App Scripts solve this: sandboxed Twig-based scripts that ship with your app and execute inside Shopware, at full speed.
What you can do with them
Add relative or absolute discounts, split line items, set custom prices, add surcharges, attach data to the cart, and raise errors or notices that the customer sees. In practice this covers the large majority of B2B pricing requirements.
Combine them with the Rule Builder
A rule-based cart script only runs when its rule matches, which keeps both the logic and the performance cost contained. 'Only for customer group Reseller, only above 50 units' belongs in the rule — not in an if-statement buried in your script.
Debug them like production code
Cart scripts touch money, and a silent one is worse than a broken one. Test them against real baskets on staging, including the ugly cases: mixed tax rates, promotions on top, and a customer who edits quantities four times.
- App Scripts avoid an HTTP call per recalculation.
- Put the 'when' in a rule, the 'what' in the script.
- Test cart scripts against ugly, real baskets.
We do this for a living — Shopware, Node.js, React, ERP integration and automation for B2B.
Talk to an engineer