> For the complete documentation index, see [llms.txt](https://docs.pakk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pakk.io/account-setup/shipping-methods/shipping-calculations.md).

# Shipping Calculations

Understand the various algorithms available for calculation of shipping charges

The simplest possible option is a `fixed` shipping charge - for example, 5 EURO. Whilst this **is** available in Pakk, it's not that useful normally. In most cases, we'll want to vary the charge based on some element of the cart/order. Pakk allows you to calculate shipping based on:

* Total order weight
* Number of items in order
* Number of units in order
* Order subtotal before tax
* Order subtotal after tax

Once you've decided on what axis you want to base this shipping method, you need to decide exactly how to perform the calculation.

#### Per-Item Delivery Surcharges <a href="#per-item-delivery-surcharges" id="per-item-delivery-surcharges"></a>

**Per-item delivery surcharges** are set at product level. If a product has a delivery surcharge of £5 set, then an extra £5 (per unit) will be factored into the total shipping cost, irrespective of the Shipping Method chosen. However, if, for a particular Shipping Method, you would like to NOT include per-item charges (for example, for a 'Collection'-type Shipping Method), you can `exclude per-item charges`.

#### Free Shipping <a href="#free-shipping" id="free-shipping"></a>

Irrespective of which calculation type you choose, you can set a threshold for free shipping. This threshold will be activated as soon as the order value (including discounts, not including payment method surcharges) is **equal to or over the threshold**. By default, the threshold is the **inc. VAT** total, which is normally the right setting for retail sites. Trade sites might want to use the **ex. VAT** order total as the threshold, which can be achieved by setting `free over is ex` to `true`.

If you decide to offer free shipping, you'll also need to decide whether to `free includes per item charges`. If you set this option to `true`, then all item delivery surcharges will also be waived once the condition for free delivery is met. If this is set to `false`, then once the condition for free delivery is met, the main delivery charge will be free, but individual item surcharges will still stand.

#### Linear <a href="#linear" id="linear"></a>

The amount charged will either go up or down depending on the value of the axis (weight/order value etc). There are quite a few sub-options:

* `base amount`, can be thought of the starting amount from where the rest of the calculation takes over.
* `over` is the threshold for the linear calculation to kick in (grams, cents or units).&#x20;
* `unit amount`, how much **extra** to charge per increment of the axis once past the `over` threshold. If you set this to a negative value, then the charge will *go down* as the increment *goes up*
* `step size`, the size of the increment you want to charge for (grams, cents or units); e.g. every additional 100 grams.

**Example 1**

We want to set up a shipping method which will cost 5 GBP for orders up to 20kg. After 20Kg we want to charge 0.20 GBP per Kg. *Note that we specify weights here in grams*:

* axis = total order weight
* `base amount` = 5.00&#x20;
* `over` = 20,000 (20Kg => 20,000 grams)
* `unit amount` = 0.20&#x20;
* `step size` = 1000 (1000 grams => 1 Kg)

**Example 2**

We want to charge a basic rate of 10 GBP, but we want this to start going down once a customer spends over 200 GBP including VAT. In fact, we'd like it to decrease by 1 GBP for every 100 GBP spent. At 1000 GBP we want shipping to be free:

* axis = order subtotal after tax
* `base amount` = 10.00
* `over` = 1000 (10 GBP => 1000 pence)
* `unit amount` = -1.00
* `step size` = 10,000 (10,000 pence => 100 GBP)
* `free over` = 100.00
* `free over is ex` = `false` (to use the \*\*inc VAT cart value)

#### Band-based <a href="#band-based" id="band-based"></a>

The amount charged will be determined by a list of band thresholds and a list of band amounts.

* `band limits` is a list of where the cutoff for each band falls, specified in units/cents/grams (depending on whether you are using units, price or weight as the axis)
* `band amounts` is a list of costs associated with each corresponding band threshold

**Example 1**

Charge in bands of 1 kg. Each band is obviously more expensive, but the difference gets smaller as the weight increases:

* `band limits`: \[ 1000, 2000, 3000, 4000, 5000]
* `band amounts`: \[ 10, 19, 27, 35, 40]


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pakk.io/account-setup/shipping-methods/shipping-calculations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
