> For the complete documentation index, see [llms.txt](https://help.pixfizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pixfizz.com/ecommerce/pixfizz-ecommerce/pixfizz-cms/extra-fees.md).

# Extra Fees

Extra fees are cart-level charges applied on top of orderline pricing. They are used for things like rush fees, minimum order surcharges, handling fees, or conditional charges based on customer type or cart contents.

### Where to configure

Admin → Shipping → Extra Fees.

### Key rules

* There can be more than one extra fee on a site.
* Extra fees are ordered, and they are evaluated in sequence — this matters when one fee's result should affect another. For example, if you have both a rush fee and a minimum order value fee, the rush fee should run first so that the minimum value calculation includes the rush amount.
* Orderline discounts are calculated **before** extra fees. This means `orderlines_discount` is available inside the extra fee formula. Discounts never apply to extra fees themselves.
* Extra fees are **ignored** (not added to the cart) if the formula produces a blank value, zero, or a negative value.
* Pixfizz bills extra fees in the same way as regular orderline transaction fees — they appear as standard line items in the billing file.

### Formula basics

Extra fee formulas use the same Ruby expression syntax as product pricing formulas, but with a restricted set of variables:

| Variable              | Description                                               |
| --------------------- | --------------------------------------------------------- |
| `orderlines_total`    | Sum of all orderline prices in the cart (after discounts) |
| `orderlines_discount` | Total discount applied to orderlines                      |

These are the **only** pricing variables available. You do not have access to `quantity`, `units`, `pages`, or any other product-level variables — extra fees operate at the cart level, not the orderline level.

### Liquid in extra fee formulas

A key difference from product pricing formulas: extra fee formulas support Liquid. The Liquid is evaluated first, and whatever it outputs is then evaluated as a Ruby pricing expression. This lets you make fees conditional on cart state, user properties, or custom fields.

#### Available Liquid variables

| Variable  | Available | Notes                         |
| --------- | --------- | ----------------------------- |
| `cart`    | Yes       | With restrictions — see below |
| `user`    | Yes       | Full access                   |
| `website` | Yes       | Full access                   |

#### Cart properties that do NOT work in extra fee formulas

These properties are excluded because they can depend on extra fees (circular dependency):

* `cart.total`
* `cart.shipping`
* `cart.discount`
* `cart.shipping_discount`
* `cart.tax`

#### Cart properties that DO work

* `cart.orderlines_total`
* `cart.orderlines_discount`
* All non-pricing properties: `cart.custom`, `cart.orderlines`, `cart.address`, `cart.shipping_option`, `cart.promocode_code`, etc.

### Shopper template codes

On Shopper-based sites, the following extra fee codes are recognised out of the box by the cart and checkout templates:

* `rush` — rush/expedited processing fee
* `min-order` — minimum order surcharge

Using these codes means the fee will display correctly in the cart summary without any custom snippet work. If you use a different code, you may need to add custom display logic.

### Examples

#### Percentage rush fee

Charge 20% of the net orderline value when the customer selects rush processing. The fee is conditional on a cart custom field called `rush`:

```liquid
{% if cart.custom.rush %}
    (orderlines_total - orderlines_discount) * 0.2
{% endif %}
```

If the custom field is not set, the Liquid outputs blank and the fee is skipped.

#### Rush fee with a minimum floor

Same as above, but the rush fee is at least $10 — whichever is greater between 25% of the net value or the $10 floor:

```liquid
{% if cart.custom.rush %}
    [(orderlines_total - orderlines_discount) * 0.25, 10].max
{% endif %}
```

For a $30 cart this returns $10.00 (the floor). For a $60 cart this returns $15.00 (25%).

#### Minimum order surcharge

Charge a fee that brings small orders up to a $5 minimum. Uses `cart.orderlines_total` in the Liquid condition to check the cart value, then returns the difference using the Ruby pricing variable:

```liquid
{% if cart.orderlines_total < 5 %}
    5 - orderlines_total
{% endif %}
```

If the cart contains $3.50 of products, this returns $1.50. If the cart is at or above $5, the Liquid outputs blank and the fee is not applied.

#### Tiered rush fee by service level

When you offer multiple rush tiers (e.g. standard rush vs same-day), use a cart custom field with distinct values rather than a simple boolean:

```liquid
{% if cart.custom.rush_option == 'standard' %}
    (orderlines_total - orderlines_discount) * 0.2
{% elsif cart.custom.rush_option == 'sameday' %}
    (orderlines_total - orderlines_discount) * 0.1
{% endif %}
```

#### Stepped rush fee by cart value

Charge a flat rush fee that scales with order size in fixed tiers rather than as a percentage:

```liquid
{% if cart.custom.rush %}
    {%- if cart.orderlines_total < 50.00 %}
    10
    {%- elsif cart.orderlines_total < 100.00 %}
    15
    {%- elsif cart.orderlines_total < 200.00 %}
    30
    {%- elsif cart.orderlines_total < 500.00 %}
    50
    {%- else %}
    75
    {%- endif %}
{% endif %}
```

Note the use of `{%-` (whitespace-trimming) on the inner conditions to ensure the formula output is clean. The outer `{% if %}` / `{% endif %}` guard ensures the fee is only applied when rush is selected.

#### Fee based on user category

Charge a $5 handling fee, but waive it for wholesale users:

```liquid
{% unless user.category == 'wholesale' %}5.00{% endunless %}
```

#### Combined: rush fee + minimum order surcharge (ordering matters)

This requires two separate extra fees configured in the correct order in the admin:

**Extra Fee 1 — Rush Fee (code: `rush`, runs first):**

```liquid
{% if cart.custom.rush %}
    (orderlines_total - orderlines_discount) * 0.2
{% endif %}
```

**Extra Fee 2 — Minimum Order Surcharge (code: `min-order`, runs second):**

```liquid
{% if cart.orderlines_total < 5 %}
    5 - orderlines_total
{% endif %}
```

Because the rush fee runs first, its value is included before the minimum order check evaluates. The ordering in the admin controls the sequence.

> **Note:** Confirm with Matjaz whether `orderlines_total` in the second fee includes the result of the first fee, or whether it always reflects the pre-extra-fee orderline total. This matters when stacking fees that depend on each other.

### Displaying extra fees on the storefront

Extra fees appear on the cart and order via `cart.extra_fees` / `order.extra_fees`, which returns an array of `ExtraFee` objects:

| Property               | Description                            |
| ---------------------- | -------------------------------------- |
| `extra_fee.name`       | Fee name (as configured in admin)      |
| `extra_fee.code`       | Fee code                               |
| `extra_fee.is_taxable` | `true` if the fee is subject to tax    |
| `extra_fee.amount`     | Fee amount — use the `currency` filter |

```liquid
{% for fee in cart.extra_fees %}
  <div class="extra-fee-line">
    <span>{{ fee.name }}</span>
    <span>{{ fee.amount | currency }}</span>
  </div>
{% endfor %}
```
