# Shipping

> How an order's goods leave the shop in YoPrint, shipments, their lines and packages, labels bought through GoShippo or elsewhere, shipment statuses, and how shipping is charged.

Web page: https://developer.yoprint.com/how-yoprint-works/shipping/

A **shipment** sends some or all of a sales order's goods to one address. Its goods go out under carrier **labels**, and each label makes one **package** per parcel. In the web app they're under **Production**: **All Shipments** and **All Packages**, and each order lists its own.

## What a shipment holds

**Diagram:** An order can have several shipments, such as one per address, or a first part and a backorder.

- **Sales order**
  - **Shipment** to one address, with a shipment status
    - **Ship to**: one of the customer's shipping addresses, and the contact who receives it
    - **Ship from**: the customer's brand profile, or the shop's location
    - **Lines**: how many of each order line go in this shipment
    - **Label**, bought through GoShippo or recorded from elsewhere
      - **Package**, one per parcel, with its size, weight, tracking number and cost
    - **Shipping cost** line, what the labels cost

A shipment line points at an order line, with a quantity: some or all of it. A **brand profile** lets a shop ship under a customer's own name and return address.

## How a shipment goes out

**Diagram:** Buying a label spends the team's money: the API has no confirmation step and no test mode.

1. **Create the shipment**: For one address on the order
2. **Add the lines**: Some or all of each order line
3. **Get rates for your boxes**: One parcel per box, with its size and weight
4. **Buy or record a label**: Through GoShippo, or one bought elsewhere with its tracking number. It makes the packages, one per parcel
5. **Ship it**: Move the shipment to an end status, such as "Shipped / Picked up"

There's no other way to make a package: packages come from labels. Buying a label through GoShippo needs a published sales order. Recording one bought elsewhere works on any sales order, but not on a quote. Removing a package asks GoShippo to void and refund its label: GoShippo or the carrier can refuse, and YoPrint doesn't report a refusal.

## Statuses

A shipment's status is the team's own, like every status. Here are the ones a new team starts with:

**Diagram:** A shipment is finished when it reaches an end status.

1. **start**: Pending
2. **in_progress**: Ready to ship, Shipment packed, In backorder
3. **end**: Shipped / Picked up

Separately, YoPrint works out whether all the jobs behind a shipment's lines have reached an end status, so the shipment can go. On an order synced from Shopify, changing the shipment's status can fulfil the order in Shopify. Every status change fires `shipment.status_changed`, the only shipment event.

## How shipping is charged

**Diagram:** The order's shipment_cost_total adds up its shipments' shipping cost lines.

1. **Label**: Its cost is in the package's `charges`
2. **Shipping cost line**: On the shipment, added when the label is bought, if you ask
3. **Shipping fee**: Billed on an invoice. With Auto Invoice, the cost reaches the order's invoice by itself

A multi-parcel label is priced as one: every package of it carries the label's full cost in `charges`, so read the master package's, and don't add them up.

## Paperwork

A shipment prints a **packing slip**, and its packages print **labels**, one by one or merged into a single PDF.

## In the API

[Ship an order](https://developer.yoprint.com/guides/shipping.md): Create a shipment, get rates, buy or record a label, and track it.

[Shipments reference](https://developer.yoprint.com/reference/shipments.md): Shipments, with their line items, packages and labels under them.
