pify/order

Orders read through the Admin API.

list and get select the same fields through one fragment, so a page and a single read return the same record. Money comes from shopMoney, in the shop’s currency.

Shopify refuses a query whose requested cost is over 1000 points, and a connection costs its first times the cost of one node. That caps the line items per order: get reads up to 90 and list up to 10, and has_more_line_items says when an order has more than were read. Only get reads the refunds, four refunds of up to fifteen lines each.

shipping_state and update_shipping_address change the shipping address of one order. They never touch the customer’s address book. cancel cancels one order.

Types

pub type Address {
  Address(
    name: option.Option(String),
    first_name: option.Option(String),
    last_name: option.Option(String),
    company: option.Option(String),
    address1: option.Option(String),
    address2: option.Option(String),
    city: option.Option(String),
    province: option.Option(String),
    province_code: option.Option(String),
    zip: option.Option(String),
    country: option.Option(String),
    country_code_v2: option.Option(String),
    phone: option.Option(String),
  )
}

Constructors

pub type CancelInput {
  CancelInput(
    order_id: String,
    reason: CancelReason,
    restock: CancelRestock,
    refund: CancelRefund,
    notice: CancelNotice,
    staff_note: option.Option(String),
  )
}

Constructors

The job that cancels the order. Shopify cancels in the background, so done is often false in the answer.

pub type CancelJob {
  CancelJob(id: String, done: Bool)
}

Constructors

  • CancelJob(id: String, done: Bool)

Whether Shopify e-mails the buyer about the cancel.

pub type CancelNotice {
  CancelNoticeNone
  CancelNoticeEmail
}

Constructors

  • CancelNoticeNone
  • CancelNoticeEmail
pub type CancelReason {
  CancelReasonCustomer
  CancelReasonDeclined
  CancelReasonFraud
  CancelReasonInventory
  CancelReasonStaff
  CancelReasonOther
  CancelReasonUnknown(raw: String)
}

Constructors

  • CancelReasonCustomer
  • CancelReasonDeclined
  • CancelReasonFraud
  • CancelReasonInventory
  • CancelReasonStaff
  • CancelReasonOther

    Shopify’s own OTHER.

  • CancelReasonUnknown(raw: String)

    A value this library does not know.

What cancel gives back to the buyer. Shopify voids an authorized payment in either case.

pub type CancelRefund {
  CancelRefundNone
  CancelRefundOriginalPayment
}

Constructors

  • CancelRefundNone
  • CancelRefundOriginalPayment

    Shopify refunds the captured payment to the payment methods it came from.

What cancel does to the stock the order holds in Shopify.

pub type CancelRestock {
  CancelRestockNone
  CancelRestockCommitted
}

Constructors

  • CancelRestockNone

    Shopify keeps its stock as it is. An app that owns the stock pushes it.

  • CancelRestockCommitted

    Shopify puts the order’s committed units back on sale.

Amounts after edits, refunds and returns, the same frame as LineItem.current_quantity.

pub type CurrentTotals {
  CurrentTotals(
    subtotal: money.Money,
    shipping: money.Money,
    tax: money.Money,
    discounts: money.Money,
    total: money.Money,
  )
}

Constructors

Names and contact fields are protected customer data. Shopify redacts them on some plans, so each one can be absent.

pub type Customer {
  Customer(
    id: String,
    first_name: option.Option(String),
    last_name: option.Option(String),
    display_name: String,
    email: option.Option(String),
    phone: option.Option(String),
  )
}

Constructors

The part of one discount, such as a discount code, that falls on a line item.

pub type DiscountAllocation {
  DiscountAllocation(allocated_amount: money.Money)
}

Constructors

pub type FinancialStatus {
  FinancialStatusPaid
  FinancialStatusPending
  FinancialStatusAuthorized
  FinancialStatusPartiallyPaid
  FinancialStatusPartiallyRefunded
  FinancialStatusRefunded
  FinancialStatusVoided
  FinancialStatusExpired
  FinancialStatusOther(raw: String)
}

Constructors

  • FinancialStatusPaid
  • FinancialStatusPending
  • FinancialStatusAuthorized
  • FinancialStatusPartiallyPaid
  • FinancialStatusPartiallyRefunded
  • FinancialStatusRefunded
  • FinancialStatusVoided
  • FinancialStatusExpired
  • FinancialStatusOther(raw: String)
pub type FulfillmentStatus {
  FulfillmentStatusFulfilled
  FulfillmentStatusUnfulfilled
  FulfillmentStatusPartiallyFulfilled
  FulfillmentStatusInProgress
  FulfillmentStatusOnHold
  FulfillmentStatusOpen
  FulfillmentStatusPendingFulfillment
  FulfillmentStatusRestocked
  FulfillmentStatusScheduled
  FulfillmentStatusRequestDeclined
  FulfillmentStatusNotRequired
  FulfillmentStatusOther(raw: String)
}

Constructors

  • FulfillmentStatusFulfilled
  • FulfillmentStatusUnfulfilled
  • FulfillmentStatusPartiallyFulfilled
  • FulfillmentStatusInProgress
  • FulfillmentStatusOnHold
  • FulfillmentStatusOpen
  • FulfillmentStatusPendingFulfillment
  • FulfillmentStatusRestocked
  • FulfillmentStatusScheduled
  • FulfillmentStatusRequestDeclined
  • FulfillmentStatusNotRequired

    No unit is left to fulfil, such as after every line was removed. Sent from 2026-10; earlier versions say UNFULFILLED.

  • FulfillmentStatusOther(raw: String)
pub type LineItem {
  LineItem(
    id: String,
    title: String,
    name: String,
    quantity: Int,
    current_quantity: Int,
    sku: option.Option(String),
    requires_shipping: Bool,
    variant: option.Option(LineItemVariant),
    original_unit_price: money.Money,
    discount_allocations: List(DiscountAllocation),
    total_discount: money.Money,
  )
}

Constructors

  • LineItem(
      id: String,
      title: String,
      name: String,
      quantity: Int,
      current_quantity: Int,
      sku: option.Option(String),
      requires_shipping: Bool,
      variant: option.Option(LineItemVariant),
      original_unit_price: money.Money,
      discount_allocations: List(DiscountAllocation),
      total_discount: money.Money,
    )

    Arguments

    quantity

    The quantity at checkout.

    current_quantity

    The quantity after edits, refunds and returns.

    variant

    Absent when the variant was deleted or the item is a custom sale.

    discount_allocations

    Each share of a discount on the line. A discount code is allocated here, never in total_discount.

    total_discount

    Only a discount set through a draft order, a script or the API.

pub type LineItemVariant {
  LineItemVariant(
    id: String,
    sku: option.Option(String),
    barcode: option.Option(String),
  )
}

Constructors

pub type ListParams {
  ListParams(
    first: Int,
    after: option.Option(String),
    updated_at_min: option.Option(String),
  )
}

Constructors

  • ListParams(
      first: Int,
      after: option.Option(String),
      updated_at_min: option.Option(String),
    )

    Arguments

    first

    Orders per page. list lowers it to max_list_first().

    updated_at_min

    An ISO 8601 UTC timestamp. Only orders updated at or after it.

A checkout field a country requires. Brazil stores the buyer’s CPF or CNPJ under the key TAX_CREDENTIAL_BR.

pub type LocalizedField {
  LocalizedField(
    key: String,
    value: String,
    country_code: String,
    purpose: String,
    title: String,
  )
}

Constructors

  • LocalizedField(
      key: String,
      value: String,
      country_code: String,
      purpose: String,
      title: String,
    )

A new shipping address for an order. Shopify overwrites the order’s address with it, so every field is sent and a None sends null.

pub type MailingAddressInput {
  MailingAddressInput(
    first_name: option.Option(String),
    last_name: option.Option(String),
    address1: String,
    address2: option.Option(String),
    city: option.Option(String),
    province_code: option.Option(String),
    zip: String,
    country_code: String,
    phone: option.Option(String),
  )
}

Constructors

  • MailingAddressInput(
      first_name: option.Option(String),
      last_name: option.Option(String),
      address1: String,
      address2: option.Option(String),
      city: option.Option(String),
      province_code: option.Option(String),
      zip: String,
      country_code: String,
      phone: option.Option(String),
    )

    Arguments

    province_code

    The region code, such as SP.

    country_code

    The two-letter country code, such as BR.

    phone

    E.164, such as +5511900000000.

pub type Money =
  money.Money
pub type Order {
  Order(
    id: String,
    legacy_resource_id: String,
    name: String,
    created_at: String,
    updated_at: String,
    processed_at: String,
    cancelled_at: option.Option(String),
    cancel_reason: option.Option(CancelReason),
    closed_at: option.Option(String),
    is_test: Bool,
    currency_code: String,
    tax_pricing: TaxPricing,
    payment_gateway_names: List(String),
    financial_status: option.Option(FinancialStatus),
    fulfillment_status: FulfillmentStatus,
    note: option.Option(String),
    email: option.Option(String),
    phone: option.Option(String),
    current_totals: CurrentTotals,
    original_totals: OriginalTotals,
    customer: option.Option(Customer),
    shipping_address: option.Option(Address),
    billing_address: option.Option(Address),
    localized_fields: List(LocalizedField),
    line_items: List(LineItem),
    has_more_line_items: Bool,
    shipping_lines: List(ShippingLine),
    refunds: RefundLines,
  )
}

Constructors

pub type OrderPage {
  OrderPage(
    orders: List(Order),
    next_cursor: option.Option(String),
    has_next_page: Bool,
  )
}

Constructors

  • OrderPage(
      orders: List(Order),
      next_cursor: option.Option(String),
      has_next_page: Bool,
    )

Amounts before returns. Shopify leaves three of them null on some orders.

pub type OriginalTotals {
  OriginalTotals(
    subtotal: option.Option(money.Money),
    shipping: money.Money,
    tax: option.Option(money.Money),
    discounts: option.Option(money.Money),
    total: money.Money,
  )
}

Constructors

pub type RefundLine {
  RefundLine(
    line_item_id: String,
    quantity: Int,
    restock: RestockType,
  )
}

Constructors

  • RefundLine(
      line_item_id: String,
      quantity: Int,
      restock: RestockType,
    )

The refunded line quantities and whether each went back to stock.

pub type RefundLines {
  RefundLinesUnread
  RefundLinesRead(lines: List(RefundLine))
  RefundLinesTruncated(lines: List(RefundLine))
}

Constructors

  • RefundLinesUnread

    list does not read refunds.

  • RefundLinesRead(lines: List(RefundLine))
  • RefundLinesTruncated(lines: List(RefundLine))

    The order has more refunds or refund lines than one read returns.

pub type RestockType {
  RestockTypeNoRestock
  RestockTypeCancel
  RestockTypeReturn
  RestockTypeLegacyRestock
  RestockTypeOther(raw: String)
}

Constructors

  • RestockTypeNoRestock

    The units stay with the buyer.

  • RestockTypeCancel

    Unfulfilled units, cancelled and back in stock.

  • RestockTypeReturn
  • RestockTypeLegacyRestock
  • RestockTypeOther(raw: String)
pub type ShippingLine {
  ShippingLine(
    title: String,
    code: option.Option(String),
    source: option.Option(String),
    original_price: money.Money,
  )
}

Constructors

What a shipping address write reads first: whether the order still ships, and the address it holds now.

pub type ShippingState {
  ShippingState(
    id: String,
    fulfillment_status: FulfillmentStatus,
    cancelled_at: option.Option(String),
    shipping_address: option.Option(Address),
  )
}

Constructors

taxesIncluded: whether the line prices and the shipping already hold the tax, or the tax comes on top of them.

pub type TaxPricing {
  TaxesIncluded
  TaxesAdded
}

Constructors

  • TaxesIncluded
  • TaxesAdded

Values

pub fn cancel(
  client: pify.Client,
  input: CancelInput,
) -> effect.Effect(
  Result(option.Option(CancelJob), error.ShopifyError),
  key,
)

Cancel one order through orderCancel. Shopify refuses an order that is cancelled already, that has a pending payment authorization or a return in progress, or whose fulfillments cannot be cancelled: the refusal is a ShopifyErrorUserErrors. None when Shopify answers no job. Needs write_scope.

pub fn cancel_job(
  client: pify.Client,
  id: String,
) -> effect.Effect(
  Result(option.Option(CancelJob), error.ShopifyError),
  key,
)

Whether the background Job of a cancel is done. None when Shopify knows no Job with this id.

pub const cancel_job_query: String
pub const cancel_mutation: String

The alias reads orderCancelUserErrors as userErrors, the field execute.run_mutation checks. The userErrors field of this payload is deprecated.

pub fn cancel_reason_to_string(reason: CancelReason) -> String
pub fn cancel_variables(input: CancelInput) -> json.Json
pub fn decoder() -> decode.Decoder(Order)
pub fn financial_status_to_string(
  status: FinancialStatus,
) -> String
pub fn fulfillment_status_to_string(
  status: FulfillmentStatus,
) -> String
pub fn gateway_names_decoder() -> decode.Decoder(List(String))
pub fn gateway_names_query() -> String
pub fn gateway_names_variables() -> json.Json
pub fn get(
  client: pify.Client,
  id: String,
) -> effect.Effect(
  Result(option.Option(Order), error.ShopifyError),
  key,
)

None when no order has this id, for example after orders/delete.

pub fn get_query() -> String
pub fn get_variables(id: String) -> json.Json
pub fn holds_address(
  current: Address,
  input: MailingAddressInput,
) -> Bool

Whether the order’s address already holds every field the input writes.

pub fn list(
  client: pify.Client,
  params: ListParams,
) -> effect.Effect(Result(OrderPage, error.ShopifyError), key)
pub fn list_query() -> String
pub fn list_variables(params: ListParams) -> json.Json
pub fn max_list_first() -> Int

The largest page list asks for without passing the cost limit.

pub fn order_cost(line_items: Int) -> Int

The requested cost of an order with line_items lines: 53 points for the order, plus 9 per line, whose discount allocations count as one node.

pub fn parse_cancel_reason(raw: String) -> CancelReason
pub fn parse_financial_status(raw: String) -> FinancialStatus
pub fn parse_fulfillment_status(raw: String) -> FulfillmentStatus
pub fn parse_restock_type(raw: String) -> RestockType
pub fn recent_gateway_names(
  client: pify.Client,
) -> effect.Effect(Result(List(String), error.ShopifyError), key)

The gateway names on the shop’s newest orders, each once, in the order first seen. A read of scalars only: no customer data leaves Shopify.

pub fn recent_shipping_titles(
  client: pify.Client,
) -> effect.Effect(Result(List(String), error.ShopifyError), key)

The shipping line titles on the shop’s newest orders, each once, in the order first seen. A read of scalars only: no customer data leaves Shopify.

pub fn restock_type_to_string(restock: RestockType) -> String
pub fn search_query(params: ListParams) -> option.Option(String)

The search expression for ListParams. None lists every order the token can read.

pub fn shipping_state(
  client: pify.Client,
  id: String,
) -> effect.Effect(
  Result(option.Option(ShippingState), error.ShopifyError),
  key,
)

None when no order has this id, for example after orders/delete. A read of a few scalars and one address.

pub fn shipping_state_query() -> String
pub fn shipping_titles_decoder() -> decode.Decoder(List(String))
pub fn shipping_titles_query() -> String
pub fn shop_money_decoder() -> decode.Decoder(money.Money)

A MoneyBag read through its shopMoney.

pub const staff_note_max: Int

The longest staffNote Shopify takes.

pub fn tax_pricing_from_bool(included: Bool) -> TaxPricing

taxesIncluded as a TaxPricing, on an order or on the shop.

pub const taxes_recalculated_since: api_version.ApiVersion

From this version a new shipping address on an unfulfilled order makes Shopify recalculate its taxes and totals. Read the order again after it.

pub fn update_shipping_address(
  client: pify.Client,
  order_id: String,
  address: MailingAddressInput,
) -> effect.Effect(Result(String, error.ShopifyError), key)

Overwrite the shipping address of one order through orderUpdate. Answers the order id. Needs write_scope.

pub const update_shipping_address_mutation: String
pub fn update_shipping_address_variables(
  order_id: String,
  address: MailingAddressInput,
) -> json.Json
pub const write_scope: String

The scope that lets an app change an order, its shipping address included. It grants read_orders too.

✨ Search Document