PHPackages                             cdmanager/magento-min-order-fee - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. cdmanager/magento-min-order-fee

ActiveMagento2-module

cdmanager/magento-min-order-fee
===============================

Magento 2 module that displays a minimum order fee as a separate total row on orders, invoices and credit memos, including admin, storefront, emails and PDFs. The fee itself is calculated and persisted by an external system.

v1.1.1(1mo ago)1111GPL-3.0-onlyPHPPHP &gt;=7.4

Since Jul 14Pushed 1mo agoCompare

[ Source](https://github.com/cdmanager/magento-min-order-fee)[ Packagist](https://packagist.org/packages/cdmanager/magento-min-order-fee)[ RSS](/packages/cdmanager-magento-min-order-fee/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

Magento Min Order Fee
=====================

[](#magento-min-order-fee)

[![Latest Stable Version](https://camo.githubusercontent.com/f4ce11bbf490f7140a0ce2880b1f417fe8ae6ad4014cb66d6ca74f36e06c1b6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63646d616e616765722f6d6167656e746f2d6d696e2d6f726465722d666565)](https://packagist.org/packages/cdmanager/magento-min-order-fee)[![Total Downloads](https://camo.githubusercontent.com/13c575da389d92ddd695f440539ba42d26ed61312efa36e667174c60a675e481/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63646d616e616765722f6d6167656e746f2d6d696e2d6f726465722d666565)](https://packagist.org/packages/cdmanager/magento-min-order-fee)[![License](https://camo.githubusercontent.com/c7ec988dda2101f054cccfcf83259830e8ede7a388a8bde4d6da0928f53d0f26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63646d616e616765722f6d6167656e746f2d6d696e2d6f726465722d666565)](https://packagist.org/packages/cdmanager/magento-min-order-fee)

A Magento 2 module that shows a **"Small Order Fee"** as a separate total row on orders, invoices and credit memos — in the admin panel, on the storefront, in sales emails and in invoice/credit memo PDFs.

The module is designed for setups where orders are created **outside the Magento checkout** (e.g. written directly to the Magento database by an external backend). It therefore does **not calculate** the fee; it only:

1. **Schema** — adds fee columns to `sales_order`, `sales_invoice` and `sales_creditmemo`.
2. **Display** — renders the fee row between Subtotal and Grand Total on admin order/invoice/credit memo screens, storefront order view/print, order emails and PDFs.
3. **Consistency** — registers invoice and credit memo total collectors so that invoices/credit memos created in the admin include the fee in their `grand_total`.
4. **API** — exposes the fee via extension attributes on the order, invoice and credit memo REST/SOAP APIs.

Requirements
------------

[](#requirements)

- Magento 2.3.x / 2.4.x (tested on 2.4.7)
- PHP 7.4+

Installation
------------

[](#installation)

### Via Composer (Packagist)

[](#via-composer-packagist)

In your Magento root directory:

```
composer require cdmanager/magento-min-order-fee
```

### Via Composer (directly from GitHub)

[](#via-composer-directly-from-github)

If the package is not (yet) available on Packagist, add the repository to your Magento project's `composer.json` first:

```
composer config repositories.magento-min-order-fee vcs https://github.com/cdmanager/magento-min-order-fee
composer require cdmanager/magento-min-order-fee
```

### Enable the module

[](#enable-the-module)

```
bin/magento module:enable Chefsdeal_MinOrderFee
bin/magento setup:upgrade
bin/magento setup:di:compile   # production mode
bin/magento cache:flush
```

`setup:upgrade` applies the declarative schema (`etc/db_schema.xml`) and creates the fee columns.

Data contract
-------------

[](#data-contract)

The external system that creates orders must populate the following columns on `sales_order`:

ColumnTypeDescription`min_order_fee`decimal(20,4)Total fee in order currency`base_min_order_fee`decimal(20,4)Total fee in base currency`min_order_fee_details`text (JSON)Optional per-brand breakdown, e.g. `[{"brand_id":1,"label":"Small Order Fee for Winco","amount":25.0}]`Rules:

- The fee is **not** an order item. `sales_order.subtotal` contains products only; `grand_total` includes the fee:

    ```
    grand_total = subtotal + shipping + tax − discount + min_order_fee

    ```
- The fee is **tax-free** — it must not affect `tax_amount`.
- In a single-currency setup, `min_order_fee == base_min_order_fee`.

### Invoices and credit memos

[](#invoices-and-credit-memos)

The module's total collectors only run inside Magento's `collectTotals()` flow (admin "Invoice"/"Credit Memo" buttons, REST API creation, payment-capture auto-invoicing). In that flow the collector derives the fee from `sales_order`, writes the `sales_invoice` / `sales_creditmemo` columns **and adds the fee to the document's `grand_total`** — do not pre-fill the columns there.

If the external system writes `sales_invoice` / `sales_creditmemo` rows **directly to the database**, `collectTotals()` never runs, so it must populate the columns itself:

- **Invoice**: copy `min_order_fee` / `base_min_order_fee` from the order. Do **not** add the fee to the invoice `grand_total` again — the order-level `grand_total` being copied already includes it. Missing columns only break the display (no fee row on invoice view/PDF); the totals stay correct.
- **Credit memo**: depends on the refund policy. If the fee is refundable, copy the remaining fee (`order fee − fee already refunded on other credit memos`) **and include it in the credit memo `grand_total`**. If the fee is non-refundable, write an explicit `0` so the intent is visible instead of a silent `NULL`.
- ⚠️ Never combine both paths: writing the columns directly **and** letting a collector run on the same document double-counts the fee in `grand_total`.

The breakdown tooltip falls back to the order's `min_order_fee_details`, so invoices/credit memos don't need a details column.

Verification
------------

[](#verification)

After deploying:

1. Check that the columns exist: `SHOW COLUMNS FROM sales_order LIKE 'min\_order\_fee%'`.
2. Create an order with a fee via the external backend; verify that the "Small Order Fee" row appears between Subtotal and Grand Total on the admin order view and that `grand_total` reconciles.
3. Create an invoice in the admin → the fee row appears in the invoice totals and `grand_total` matches the order.
4. Create a full/partial credit memo → the fee appears in the credit memo totals and is not double-counted (order fee − already refunded).
5. Verify the fee row in the order confirmation email and the invoice PDF.
6. For multi-brand orders, hover over the row label → the tooltip shows the per-brand breakdown from `min_order_fee_details`.

File map
--------

[](#file-map)

```
├── registration.php
├── etc/
│   ├── module.xml
│   ├── db_schema.xml                      # fee columns
│   ├── db_schema_whitelist.json
│   ├── extension_attributes.xml           # order/invoice/creditmemo API fields
│   ├── sales.xml                          # invoice & creditmemo total collectors
│   └── config.xml                         # PDF (invoice/creditmemo) total row
├── Model/Total/
│   ├── Invoice/MinOrderFee.php            # adds the fee to invoice grand_total
│   └── Creditmemo/MinOrderFee.php         # adds the fee to creditmemo grand_total
├── Block/
│   ├── Adminhtml/Totals/MinOrderFee.php   # admin order/invoice/creditmemo totals
│   └── Order/Totals/MinOrderFee.php       # storefront + email totals
└── view/
    ├── adminhtml/
    │   ├── layout/                        # sales_order_view, invoice view/new, creditmemo view/new
    │   └── templates/order/totals/min_order_fee.phtml
    └── frontend/
        ├── layout/                        # sales_order_view, sales_order_print, sales_email_order_items
        └── templates/order/totals/min_order_fee.phtml

```

Notes
-----

[](#notes)

- **Email/PDF block names can be theme-dependent.** The `order_totals` layout reference works with the standard themes; a customized theme may need extra layout handles for invoice/credit memo emails (`sales_email_order_invoice_items`, `sales_email_order_creditmemo_items`).
- **Tooltip** is currently a plain `title` attribute (native browser tooltip). A rich tooltip requires a theme-side JS/CSS component.
- If you add new columns, regenerate the whitelist with:

    ```
    bin/magento setup:db-declaration:generate-whitelist --module-name=Chefsdeal_MinOrderFee
    ```

License
-------

[](#license)

GPL-3.0-only — see [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

4

Last Release

39d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

v1.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/445349?v=4)[Sinan Eldem](/maintainers/sineld)[@sineld](https://github.com/sineld)

---

Top Contributors

[![sineld](https://avatars.githubusercontent.com/u/445349?v=4)](https://github.com/sineld "sineld (5 commits)")

### Embed Badge

![Health badge](/badges/cdmanager-magento-min-order-fee/health.svg)

```
[![Health](https://phpackages.com/badges/cdmanager-magento-min-order-fee/health.svg)](https://phpackages.com/packages/cdmanager-magento-min-order-fee)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1162.0M19](/packages/mollie-magento2)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68365.7k](/packages/run-as-root-magento2-prometheus-exporter)[dotdigital/dotdigital-magento2-extension

Dotdigital for Magento 2

50413.8k26](/packages/dotdigital-dotdigital-magento2-extension)[yireo/magento2-emailtester2

Preview transactional emails and test send them in your backend

34452.5k](/packages/yireo-magento2-emailtester2)[buckaroo/magento2

Buckaroo Magento 2 extension

32431.3k8](/packages/buckaroo-magento2)[mage-os/module-rma

Return Merchandise Authorization

229.1k](/packages/mage-os-module-rma)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
