Skip to content

About

A Shopware 6 plugin that automatically adds configurable surcharges to the shopping cart, including logistic fees and cash on delivery charges with dynamic payment method detection.

Topics

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

ActOrderSurcharges - Shopware Plugin

A Shopware 6 plugin that automatically adds configurable surcharges to the shopping cart, including logistic fees and cash on delivery charges with dynamic payment method detection.

Requirements

  • Shopware >=6.7 <6.8, tested with 6.7.16.0
  • PHP 8.4 or higher

Features

  • Automatic logistic surcharge for all orders, as a fixed amount or a percentage of the goods value with optional minimum and maximum
  • Cash on delivery (COD) fee based on payment method selection
  • Dynamic surcharge calculation with proper tax handling
  • Automatic cart cleanup when items are removed
  • Payment method change detection and fee adjustment
  • Configurable surcharge amounts through admin panel
  • Multi-language support (German & English)

Installation

Via Composer (recommended)

composer require actualizer/order-surcharges
bin/console plugin:refresh
bin/console plugin:install --activate ActOrderSurcharges
bin/console cache:clear

Manual

  1. Download or clone this plugin into your custom/plugins/ directory
  2. Install and activate the plugin via CLI:
    bin/console plugin:refresh
    bin/console plugin:install --activate ActOrderSurcharges
    bin/console cache:clear

Configuration

  1. Go to Admin Panel → Settings → System → Plugins
  2. Find "Actualize: Order Surcharges" and click on the three dots
  3. Click "Config" to access plugin settings

Configuration Options

Logistic Surcharge

  • Active: Enable/disable the logistic surcharge
  • Calculation: "Fixed amount" (default) or "Percentage of the goods value"
  • Logistic Surcharge Amount: Fixed amount added to all orders (default: 4.95 €), used with "Fixed amount"
  • Percentage of the goods value: e.g. 5 for 5 %, used with "Percentage of the goods value"
  • Minimum amount / Maximum amount: Optional limits for the percentage surcharge; empty or 0 means no limit
  • Show percentage in the line item name: Labels the line item e.g. "Logistic surcharge (5%)" (default: off)

Only the fields of the selected calculation are shown; percentage, minimum and maximum share one row.

Cash on Delivery Fee

  • Active: Enable/disable COD fees
  • COD Fee Amount: Fee amount for cash on delivery payments (default: 5.95 €)
  • Cash on delivery payment method: Payment method that triggers the fee. If empty, the payment method is recognised by its name (see below)

Tax Settings

  • Default Tax Rate: Tax rate used when no other rate can be determined (default: 19.0%)

How it works

Logistic Surcharge

  1. Automatic Addition: Added to cart when at least one regular product is present
  2. Cart Cleanup: Automatically removed when cart becomes empty
  3. Tax Calculation: Uses appropriate tax rate based on cart contents or configuration

Percentage of the goods value

  • The base is the total of all products minus promotions (discounts and vouchers). Shipping costs, the cash on delivery fee and the surcharge itself are not part of it.
  • The base is taken in the price display of the customer: gross for gross customer groups, net for net customer groups. Fixed amount, minimum and maximum are interpreted the same way.
  • The result is raised to the minimum amount or capped at the maximum amount, then rounded like any other cart price.
  • With "Show percentage in the line item name" the percentage appears in the label, formatted for the customer's language ("5 %", "2,5 %" in German). When the minimum or maximum amount applies, the label shows the plain name, as the percentage would not match the amount.
  • Example with 5 %, minimum 3.00 € and maximum 25.00 €: 100 € goods → 5.00 €, 20 € goods → 3.00 €, 2,000 € goods → 25.00 €.

Cash on Delivery Fee

  1. Payment Detection: Monitors payment method selection for COD variants
  2. Dynamic Addition: Fee added when COD payment method is selected
  3. Automatic Removal: Fee removed when different payment method is chosen
  4. Payment Method Selection: Uses the configured payment method, or falls back to name detection (Nachnahme, Cash on Delivery, COD)

Tax Handling

  • Inherits the tax rate from the products in the cart; with mixed tax rates the surcharge is split by the share each rate has in the goods value (same as Shopware's automatic shipping tax)
  • Falls back to context tax rules
  • Uses configured default tax rate as final fallback
  • Proper tax calculation with Shopware's tax system

Technical Details

Architecture

  • Uses CartProcessorInterface for clean cart integration
  • SalesChannelContextSwitchEvent for payment method change detection
  • Line items with unique IDs (logistic-surcharge, cod-fee)
  • Proper price definitions with tax calculations

Payment Method Detection

If a payment method is selected in the configuration, only that payment method triggers the fee.

Otherwise COD payments are detected by checking payment method names for:

  • nachnahme (German)
  • cash on delivery (English)
  • cod (abbreviation, whole word only)

Development

Building/Testing

After making changes:

bin/console cache:clear
bin/console theme:compile

Debugging

  • Check cart contents in browser developer tools
  • Monitor Shopware logs for surcharge-related events
  • Test payment method changes in checkout process

Usage Examples

Standard Shopping Cart

  1. Customer adds products to cart
  2. Logistic surcharge automatically added
  3. Total price includes surcharge + tax

Cash on Delivery Order

  1. Customer proceeds to checkout
  2. Selects COD payment method
  3. COD fee automatically added to cart
  4. Changes to different payment → COD fee removed

Empty Cart Handling

  1. Customer removes all products
  2. All surcharges automatically removed
  3. Clean cart state maintained

Compatibility

  • Payment Methods: Compatible with all standard Shopware payment providers
  • Tax Systems: Works with all Shopware tax configurations

Support

For issues and feature requests, please use the GitHub issue tracker.

License

This plugin is licensed under the MIT License - see the LICENSE file for details.

Credits

Developed by Actualize


Made with ❤️ for the Shopware Community

About

A Shopware 6 plugin that automatically adds configurable surcharges to the shopping cart, including logistic fees and cash on delivery charges with dynamic payment method detection.

Topics

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages