Charging Handling Fees for Hazmat, Oversized, and Cold-Chain Products in Magento 2
How we set up hazmat, oversized, and cold-chain handling fees in Magento 2 with attribute conditions, plus minimum order and cash on delivery fees.

Some products cost more to ship than the shipping rate admits. Lithium batteries need hazmat paperwork. A kayak needs a truck. Frozen goods need insulated packaging and dry ice. Stores usually eat these costs, pad every shipping rate, or bury them in product prices. All three punish the customers who did not buy the expensive-to-ship item.
The cleaner answer is a fee that exists only when the cart contains the thing that causes the cost, labeled so the shopper can see what it is. That is attribute-triggered fees, and it is the main reason we built the OCM Labs Extra Fees module. Here is how we set these up, using the module we sell.
How do you charge a handling fee only on certain products?
With the OCM Labs Extra Fees module for Magento 2, you mark the products with a product attribute and create a fee whose condition matches that attribute value. The fee fires only when a matching item is in the cart, and it renders as its own labeled line in cart and checkout totals, so a shopper with no hazmat items never sees a hazmat fee.
The setup is two steps. First, a select attribute on your products, something like special_handling with options for Hazmat, Oversized, and Cold Chain, assigned to the relevant attribute sets and set on the affected SKUs.
Second, one fee per handling type under Sales > Extra Fees > Manage Fees, each with a condition on that attribute. The condition builder loads attribute values by AJAX from your catalog, so you pick "Hazmat" from a dropdown rather than looking up option IDs. Conditions store the option ID, not the label, which means renaming the option later never silently breaks the fee. Configurable products are checked on both parent and selected child, so a variant-level attribute, like the size that makes one variant oversized, still triggers. The full mechanics are in the fees and conditions docs.
If you cannot maintain an attribute, SKU conditions work too, with autocomplete search and one row per SKU combined with OR. Past a dozen SKUs, though, the attribute is less to maintain.
Hazmat: a fixed fee
Hazmat handling is usually a flat compliance cost: the paperwork and packaging cost roughly the same whether the cart has one flagged item or five. That is a fixed fee, entered in base currency. A $10 fixed fee is $10 whether one hazmat item or ten are in the cart, which matches how the carrier bills you for it.
Name the fee what the shopper should read, because the fee name is the line item label. "Hazardous Materials Handling" explains itself at checkout. "Surcharge" invites a support ticket.
Oversized: fixed, or percentage with caps
For oversized items, a flat fee often works. When the cost scales with what was bought, a percentage fee fits better, and this is where the calculation base matters: percentage fees compute from the pre-discount, tax-exclusive row totals of the matching items only, not the whole cart. A shopper buying a $900 kayak and $100 of accessories pays the oversized percentage on the kayak, not on the paddles.
Percentage fees take optional min and max caps in base currency. The docs example is the pattern we use: a 2% fee capped between $5 and $50 always charges between $5 and $50 no matter the cart size. The floor stops the 40-cent fee line that looks like a rounding error; the ceiling stops the fee nobody can defend on the phone.
Cold chain: percentage on the refrigerated items, scheduled if you want
Cold-chain packaging costs scale with how much needs to stay cold, so a percentage fee on the matching items fits naturally, again computed from just the flagged items' row totals.
If your cold-chain costs are seasonal, the fee can be too. Every fee takes optional Active From and Active To dates, evaluated in the store view's own timezone, so a summer-only insulated packaging fee runs June through August and shuts itself off without anyone remembering to disable it. Details are in the scoping and scheduling docs.
These fees stack, on purpose
Every fee whose conditions match fires, each as its own line. A cart with a hazmat item and an oversized item shows both fees, separately labeled, which is exactly what you want for costs that genuinely both exist. The thing to watch is accidental overlap: if one product carries both flags and you meant the fees to be either/or, add an Is Not condition to one of them. There is no priority system to sort it out for you.
What about a minimum order fee in Magento 2?
A minimum order fee is one cart condition: a $5 fixed fee with Cart Subtotal < 50, done. The subtotal comparison is always in the store's base currency, worth remembering on multi-currency stores.
Decide first whether you want to charge small orders or refuse them, because Magento core already handles the refusing: Stores > Configuration > Sales > Sales > Minimum Order Amount blocks checkout entirely below a threshold. The core setting protects your margin by turning customers away. The fee keeps the sale and makes it worth processing. B2B stores usually block; retail stores usually charge. Just do not do both against the same threshold, or nobody ever sees the fee.
How do you add a cash on delivery extra fee?
One fee, one condition: Payment Method Is cashondelivery, the code for Magento's built-in cash on delivery method. COD orders carry real extra cost, failed deliveries and cash handling among them, so a labeled fee is fair and common.
Know when it appears: payment method conditions never match until the shopper has actually selected a payment method, so the COD fee shows in the checkout order summary at the payment step, never on the cart page, and the total updates before the order is placed. We went deeper on payment and shipping surcharges, including the card-brand and state rules for credit card fees, in Magento 2 surcharges by payment method, shipping method, and customer group.
What makes a handling fee defensible
Two properties, and both come standard here. First, the shopper sees the fee at checkout as a named line, not a mystery bump in the total, and each store view can carry its own label translation for multi-language stores. Second, the fee survives the paperwork: it shows on the order, the invoice, the credit memo, the emails, and the PDFs, and it refunds correctly when the order comes back. A fee that appears at checkout and then vanishes from the invoice email generates exactly the support conversation it was supposed to prevent. That lifecycle behavior is its own topic, and we wrote it up in what happens to checkout fees on invoices and credit memos.
The OCM Labs Extra Fees module is $250 for Magento Open Source, $500 for Adobe Commerce, version 1.1.0, for Magento 2.4.7 to 2.4.8 on PHP 8.3+, Luma and Hyva. It is one of five modules we sell under the OCM Labs brand; the rest are on our Magento extensions page.
✦ FAQ
How do I charge a handling fee for specific products in Magento 2?+–
Can I charge a hazmat fee per item instead of per order?+–
How do I set up a minimum order fee in Magento 2?+–
How do I add an extra fee for cash on delivery in Magento 2?+–
Do stacked handling fees show as one combined line at checkout?+–
Will a handling fee still show correctly on invoices and refunds?+–

Shane Blandford
Founder of Orange Collar Media, a Denver ecommerce agency behind 800+ Magento and Shopify builds. In Magento since version 1.x - building, rescuing, and supporting revenue-critical stores since 2008.
✦ KEEP READING
Related from the Journal.
How to Add Extra Fees to Magento 2 Checkout: Custom Code vs Extension
Two ways to add an extra fee to Magento 2 checkout: a custom totals collector (with working code) or an extension. What each handles, what each breaks.

Magento 2 Surcharges by Payment Method, Shipping Method, and Customer Group
How to add Magento 2 surcharges by payment method, shipping method, or customer group, plus the card-brand and state rules to check before you do.

Magento 2 Checkout Fees Done Right: Tax, Invoices, Credit Memos, Refunds
A checkout fee is the easy part. Here is how Magento 2 fees should behave through tax, partial invoices, credit memos, and refunds, and where DIY breaks.
