The order module

class magento.models.order.Order(data, client)[source]View on GitHub

Bases: Model

Wrapper for the orders endpoint

DOCUMENTATION: str = 'https://adobe-commerce.redoc.ly/2.3.7-admin/tag/orders'

Link to the Official Magento 2 API documentation for the endpoint wrapped by the Model

IDENTIFIER: str = 'entity_id'

The API response field that the endpoint’s uid comes from

__init__(data, client)[source]View on GitHub

Initialize an Order object using an API response from the orders endpoint

Parameters
  • data (dict) – API response from the orders endpoint

  • client (Client) – an initialized Client object

property excluded_keys: List[str]

API response keys that shouldn’t be set as object attributes by set_attrs()

Returns

list of API response keys that shouldn’t be set as attributes

property id: int

Alias for entity_id

property number: str

Alias for increment_id

property items: List[OrderItem]

The ordered items, returned as a list of OrderItem objects

Note

When a configurable Product is ordered, the API returns data for both the configurable and simple product

  • The OrderItem is initialized using the configurable product data, since the simple product data is incomplete

  • The product and product_id will still match the simple product though

If both entries are needed, the unparsed response is in the data dict

property item_ids: List[int]

The item_id s of the ordered items

property products: List[Product]

The ordered items, returned as their corresponding Product objects

get_invoice()[source]View on GitHub

Retrieve the Invoice of the Order

Return type

Invoice

property shipping_address: dict

Shipping details, from extension_attributes.shipping_assignments

property bill_to: dict

Condensed version of the billing_address dict

property bill_to_address: str

The billing address, parsed into a single string

property ship_to: dict

Condensed version of the shipping_address dict

property ship_to_address: str

The shipping address, parsed into a single string

property payment: dict

Payment data

property net_tax: float

Final tax amount, with refunds and cancellations taken into account

property net_total: float

Final Order value, with refunds and cancellations taken into account

property item_refunds: float

Total amount refunded for items; excludes shipping and adjustment refunds/fees

property total_qty_invoiced: int

Total number of units invoiced

property total_qty_shipped: int

Total number of units shipped

property total_qty_refunded: int

Total number of units refunded

property total_qty_canceled: int

Total number of units canceled

property total_qty_outstanding: int

Total number of units that haven’t been shipped/fulfilled yet

property net_qty_ordered: int

Total number of units ordered, after accounting for refunds and cancellations

class magento.models.order.OrderItem(item, client=None, order=None)[source]View on GitHub

Bases: Model

Wrapper for the order/items endpoint

DOCUMENTATION: str = 'https://adobe-commerce.redoc.ly/2.3.7-admin/tag/ordersitems'

Link to the Official Magento 2 API documentation for the endpoint wrapped by the Model

IDENTIFIER: str = 'item_id'

The API response field that the endpoint’s uid comes from

__init__(item, client=None, order=None)[source]View on GitHub

Initialize an OrderItem using an API response from the orders/items endpoint

Note

Initialization requires either a Client or Order object

Parameters
  • item (dict) – API response from the orders/items endpoint

  • order (Optional[Order]) – the Order that this is an item of

  • client (Optional[Client]) – the Client to use (if not initializing with an Order)

Raises

ValueError – if both the order and client aren’t provided

property excluded_keys: List[str]

API response keys that shouldn’t be set as object attributes by set_attrs()

Returns

list of API response keys that shouldn’t be set as attributes

property order: Order

The corresponding Order

property product: Product

The item’s corresponding Product

Note

If the ordered item:

  • Is a configurable product - the child simple product is returned

  • Has custom options - the base product is returned

property product_id: int

Id of the corresponding simple Product

property extension_attributes: dict
property qty_outstanding: int

Number of units that haven’t been shipped/fulfilled yet

property net_qty_ordered: int

Number of units ordered, after accounting for refunds and cancellations

property net_tax: float

Tax amount after accounting for refunds and cancellations

property net_total: float

Row total (incl. tax) after accounting for refunds and cancellations

property net_refund: float

Refund amount after accounting for tax and discount refunds

property total_canceled: float

Cancelled amount; note that partial cancellation is not possible