Blog US Shopware Agency

Premium Order Protection on Shopware 6: custom line items, Avalara, and how we build plugins

· 9 min read · By Irish Titan

Optional checkout fees—warranty-style order protection—do not ship as a product in your PIM. They are a policy line with their own UX, session rules, and tax behavior. On a recent US B2B Shopware 6 storefront, we implemented Premium Order Protection as a reusable static plugin and wired it through the same cart and tax stack as merchandise, including Avalara (MoptAvalara6) where the vendor package only understood catalog lines out of the box.

Checkout: Premium Order Protection card with shield icon, short coverage copy, and on-off toggle.
Storefront opt-in: the protection line is presented as its own card with a toggle so shoppers see coverage and price context without cluttering the product list.

What the plugin does

Customers see a clear opt-in card at checkout (shield icon, short copy about damage, theft, or loss in transit). The fee is the greater of a $1.00 floor or 2% of the cart merchandise subtotal—calculated from real product line items only, so shipping, discounts, and the fee itself do not skew the base. Preference lives in session (on by default, unless the shopper turns it off or removes the line), and the fee is hidden from generic line-item lists so the cart does not read like a duplicate “mystery product”; it still surfaces in the checkout summary between shipping and totals where finance expects it.

How it works in Shopware

Under the hood the fee is a custom line item with a stable id (premium-protection-fee), payload flags (premiumProtection), and a dedicated type string so other extensions can recognize it. A subscriber reconciles the line on cart change, quantity updates, and removals: it recalculates when the basket changes, strips the fee when the cart is empty, respects “manually removed” and DELETE-style API removals, and resets flags for admin order creation so operations staff are not fighting storefront session state.

A small storefront controller exposes routes such as status JSON, ensure-on-cart POST, and a form POST toggle that redirects back to the referrer—simple, cache-friendly, and easy to allow-list at the edge (same pattern we use for other checkout-adjacent paths).

Tax engine integration (why we patched MoptAvalara6)

Avalara’s Shopware adapter maps product numbers to AvaTax lines. Custom fees do not have a catalog product number the same way, so GetTax could not attach tax cleanly to the protection line. We shipped a focused Composer patch that (1) falls back to the line item id when building AvaTax lines, and (2) extends OverwritePriceProcessor so custom items carrying the premiumProtection payload receive the same post-calculation treatment as products—using Avalara’s returned row when present, with a controlled fallback to an inferred rate when AvaTax does not return a dedicated row.

That keeps checkout totals, committed orders, and reconciliation aligned with what Avalara calculated, instead of bolting on parallel “fake tax” only in the storefront.

Playing nicely with the rest of the stack

Because the fee is a first-class line item, sibling plugins can branch on it deliberately: for example, store credit flows can refuse to apply when protection is active (avoiding double-use of margin), and carrier rating logic can skip the synthetic line so UPS account or ShipperHQ paths are not polluted. Those guardrails are explicit string checks—not heuristics on label text—so refactors stay grep-able.

Our Shopware plugin-building approach

  • Static plugin in-repo (custom/static-plugins/…, Composer path repo) so the behavior is versioned with the merchant project, not hidden in a one-off theme.
  • Theme-independent Twig + SCSS colocated with the plugin, with the storefront theme only pulling assets via @PremiumOrderProtection where needed—upgrade the theme without losing checkout UX.
  • Narrow patches to marketplace packages when the integration boundary is vendor code; document the patch in composer.json / patches.lock.json and re-validate on extension upgrades.
  • Operational hooks: structured logging during bring-up, admin-safe resets, and edge/CDN rules for new storefront routes.

Irish Titan is a Shopware Platinum partner—see our profile on Shopware. US checkout work ships with the same Titan-only delivery model: Irish Titan employees from our headquarters, accountable for plugins, patches, and go-live.

Talk with the team

Share your stack, timeline, and what “success” looks like for US Shopware Agency. We read every message and respond quickly—routing to Irish Titan employees at our headquarters (Titan-only; no contractor inbox).

Message received

Open for business: in office hours and responding. Open

You are writing to real people—not a bot or a ticket void. On weekdays during business hours (9:00 am–5:00 pm CDT), we aim to reply within about an hour. Outside those times we still respond by hand; it may take a little longer.

Tired of forms? Text us.

Email us (info@irishtitan.com)