# Orders

User order retrieval and cancellation

## List authenticated user's orders

> Retrieves paginated list of orders for the authenticated user.\
> Includes order items, discounts, addresses, and payment details.\
> \
> For guest users, returns only the most recent order.\
> \
> Supports filtering and search by order number.

```json
{"openapi":"3.1.0","info":{"title":"Users API - Authentication, Password, Orders, and Hooks","version":"1.0.0"},"tags":[{"name":"Orders","description":"User order retrieval and cancellation"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"cookie","name":"sessionid","description":"Session cookie for authentication"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"schema":{"type":"string"},"description":"Session cookie in format `sessionid=<value>`.\nMay use site-specific cookie name (e.g., `osessionid`)."}},"schemas":{"UserOrder":{"type":"object","description":"User order with all related data including items, discounts, addresses, and payment details.","properties":{"pk":{"type":"integer","description":"Order ID"},"number":{"type":"string","description":"Order number (unique identifier)"},"status":{"$ref":"#/components/schemas/EnumValue"},"currency":{"$ref":"#/components/schemas/EnumValue"},"amount":{"type":"string","description":"Order total amount"},"discount_amount":{"type":"string","description":"Total discount applied"},"amount_without_discount":{"type":"string","description":"Amount before discounts (computed field)"},"shipping_amount":{"type":"string","description":"Shipping cost"},"shipping_tax_rate":{"type":["string","null"],"description":"Tax rate for shipping"},"refund_amount":{"type":"string","description":"Total refund amount"},"discount_refund_amount":{"type":"string","description":"Refunded discount amount"},"shipping_refund_amount":{"type":"string","description":"Refunded shipping amount"},"is_cancelled":{"type":"boolean","description":"Whether order is fully cancelled"},"is_cancellable":{"type":"boolean","description":"Whether order can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether order is eligible for refund"},"is_payable":{"type":"boolean","description":"Whether order has pending payment"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"order_type":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}],"description":"Type of order. Possible values:\n- `regular`: Standard order placed by customer\n- `addon`: Additional items added to an existing order\n- `replacement`: Replacement order for defective/incorrect items\n\nField can be null for legacy orders created before order_type was introduced."},"user_email":{"type":"string","format":"email","description":"Email address used for order"},"has_gift_box":{"type":["boolean","null"],"description":"Whether order includes gift box"},"gift_box_note":{"type":["string","null"],"description":"Gift box message/note"},"notes":{"type":["string","null"],"description":"Order delivery instructions"},"installment_count":{"type":"integer","description":"Number of payment installments"},"installment_interest_amount":{"type":"string","description":"Interest amount for installment payment"},"bin_number":{"type":["string","null"],"description":"Credit card BIN number (first 6-8 digits)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"},"shipping_address":{"$ref":"#/components/schemas/Address"},"billing_address":{"$ref":"#/components/schemas/Address"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"client_type":{"$ref":"#/components/schemas/EnumValue"},"payment_option":{"$ref":"#/components/schemas/PaymentOptionSummary"},"bank":{"oneOf":[{"$ref":"#/components/schemas/BankSummary"},{"type":"null"}],"description":"Bank information (null if not credit card payment)"},"extra_field":{"type":["object","null"],"description":"Additional order data (rewards, custom fields, etc.)"},"orderitem_set":{"type":"array","items":{"$ref":"#/components/schemas/UserOrderItem"}},"discountitem_set":{"type":"array","items":{"$ref":"#/components/schemas/DiscountItem"}},"loyaltytransaction_set":{"type":"array","items":{"$ref":"#/components/schemas/LoyaltyTransaction"}}}},"EnumValue":{"type":"object","description":"Enum representation with value and label","properties":{"value":{"type":"string","description":"Enum internal value"},"label":{"type":"string","description":"Human-readable label"}}},"Address":{"type":"object","description":"Address details with location references","properties":{"pk":{"type":"integer"},"email":{"type":["string","null"],"format":"email"},"phone_number":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"country":{"$ref":"#/components/schemas/LocationSummary"},"city":{"$ref":"#/components/schemas/LocationSummary"},"line":{"type":"string","description":"Full address line"},"title":{"type":"string","description":"Address title/label"},"township":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"district":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"postcode":{"type":["string","null"]},"notes":{"type":["string","null"],"description":"Additional delivery instructions"},"company_name":{"type":["string","null"],"description":"Company name for corporate addresses"},"tax_office":{"type":["string","null"]},"tax_no":{"type":["string","null"]},"e_bill_taxpayer":{"type":["boolean","null"],"description":"E-bill taxpayer status"},"hash_data":{"type":"string","description":"Address hash for deduplication"},"address_type":{"$ref":"#/components/schemas/EnumValue"},"retail_store":{"oneOf":[{"type":"object","description":"Retail store details for store pickup addresses"},{"type":"null"}]},"remote_id":{"type":["string","null"],"description":"Remote system identifier"},"identity_number":{"type":["string","null"],"description":"Identity/tax number"},"extra_field":{"type":["object","null"],"description":"Additional custom fields"},"user":{"type":["integer","null"],"description":"User ID who owns this address"},"is_corporate":{"type":["boolean","null"],"description":"Whether this is a corporate address"},"primary":{"type":["boolean","null"],"description":"Whether this is the primary address"}}},"LocationSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"code":{"type":"string"}}},"PaymentOptionSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"payment_type":{"type":"string"},"slug":{"type":"string"}}},"BankSummary":{"type":"object","description":"Bank information for payment","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"],"format":"uri","description":"Bank logo image URL"},"logo_path":{"type":["string","null"],"description":"Alternative path for bank logo"}}},"UserOrderItem":{"type":"object","description":"Order item within an order. Includes product details, pricing, status, and cancellation information.","properties":{"pk":{"type":"integer","description":"Order item ID"},"product":{"$ref":"#/components/schemas/UserOrderProduct"},"order":{"type":"integer","description":"Parent order ID"},"price":{"type":"string","description":"Total price for this order item"},"tax_rate":{"type":"string","description":"Tax rate applied"},"retail_price":{"type":["string","null"],"description":"Original retail price before discounts"},"discount_amount":{"type":["string","null"],"description":"Discount applied to this item"},"discounted_price":{"type":"string","description":"Final price after discount (computed field)"},"status":{"$ref":"#/components/schemas/EnumValue"},"price_currency":{"$ref":"#/components/schemas/EnumValue"},"is_cancelled":{"type":"boolean","description":"Whether item is cancelled"},"is_cancellable":{"type":"boolean","description":"Whether item can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether item is eligible for refund"},"is_tradable":{"type":"boolean","description":"Whether item is eligible for trade-in"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL for this item"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number for this item"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"shipping_option_group":{"oneOf":[{"$ref":"#/components/schemas/ShippingOptionGroup"},{"type":"null"}]},"estimated_delivery_date":{"type":["string","null"],"format":"date","description":"Estimated delivery date"},"shipped_date":{"type":["string","null"],"format":"date-time","description":"Date when item was shipped"},"delivered_date":{"type":["string","null"],"format":"date-time","description":"Date when item was delivered"},"image":{"type":["string","null"],"format":"uri","description":"Order item image (may differ from product image)"},"attributes":{"type":["object","null"],"description":"Item-specific attributes (e.g., trade-in inquiry data)"},"attributes_kwargs":{"type":["object","null"],"description":"Attribute configuration parameters"},"extra_field":{"type":["object","null"],"description":"Additional item data"},"cancellationrequest_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequest"}},"active_cancellation_request":{"oneOf":[{"$ref":"#/components/schemas/CancellationRequest"},{"type":"null"}],"description":"Most recent active cancellation request if exists"},"available_easy_return_shipping_companies":{"type":"array","items":{"$ref":"#/components/schemas/EasyReturnShippingCompany"},"description":"Available shipping companies for easy return"},"datasource_detailed":{"type":["object","null"],"description":"Data source information (if applicable)"},"extra_product_stock_detailed":{"type":["object","null"],"description":"Extra product stock details (if applicable)"},"extra_product_price_detailed":{"type":["object","null"],"description":"Extra product price details (if applicable)"}}},"UserOrderProduct":{"type":"object","description":"Product information in order context, including translations and attributes.","properties":{"pk":{"type":"integer","description":"Product ID"},"sku":{"type":"string","description":"Stock keeping unit"},"base_code":{"type":"string","description":"Product base code"},"name":{"type":"string","description":"Product name (translated)"},"image":{"type":["string","null"],"format":"uri","description":"Product image URL"},"absolute_url":{"type":"string","description":"Product detail page URL"},"attributes":{"type":"object","description":"Product attributes as key-value pairs"},"attributes_kwargs":{"type":"object","description":"Attribute configuration parameters"},"form_schema":{"type":"array","description":"Form configuration for product attributes"},"data_source":{"type":["object","null"],"description":"Data source information"},"extra_attributes":{"type":"object","description":"Additional product attributes"},"category":{"type":["object","null"],"description":"Main category information"},"attribute_set":{"type":"array","description":"Product attribute set"}}},"ShippingOptionGroup":{"type":"object","description":"Shipping option group information for order item","properties":{"pk":{"type":"integer","description":"Shipping option group ID"},"amount":{"type":"string","description":"Shipping amount"},"shipping_option_name":{"type":"string","description":"Name of shipping option"},"shipping_option_logo":{"type":["string","null"],"format":"uri","description":"Logo/icon of shipping option"}}},"CancellationRequest":{"type":"object","description":"Cancellation request record (response)","properties":{"pk":{"type":"integer"},"uuid":{"type":"string","format":"uuid","description":"Unique identifier for the cancellation request"},"order_item":{"type":"integer","description":"Order item ID"},"reason":{"type":"integer","description":"Cancellation reason ID"},"cancellation_type":{"$ref":"#/components/schemas/EnumValue"},"status":{"$ref":"#/components/schemas/EnumValue"},"description":{"type":["string","null"],"description":"User-provided cancellation description"},"iban":{"type":["string","null"],"description":"IBAN for refund (for cash payment orders)"},"holder_name":{"type":["string","null"],"description":"Account holder name for refund"},"easy_return":{"oneOf":[{"$ref":"#/components/schemas/CancellationEasyReturn"},{"type":"null"}],"description":"Easy return shipping information (for refund type cancellations)"},"quantity":{"type":["integer","null"],"description":"Quantity being cancelled (for mergeable order items)"},"fully_refund_as_loyalty_money":{"type":["boolean","null"],"description":"Whether refund is issued as loyalty points"},"cancellation_request_image_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequestImage"},"description":"Images attached to the cancellation request"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"CancellationEasyReturn":{"type":"object","description":"Easy return shipping details","properties":{"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"code":{"type":"string","description":"Easy return code/reference"},"start_date":{"type":["string","null"],"format":"date-time","description":"Pickup window start date"},"end_date":{"type":["string","null"],"format":"date-time","description":"Pickup window end date"},"status":{"$ref":"#/components/schemas/EnumValue"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"pickup_date":{"type":["object","null"],"description":"Selected pickup date and time slot","properties":{"date":{"type":"string","format":"date","description":"Pickup date in YYYY-MM-DD format"},"hour_range":{"type":"object","properties":{"start":{"type":"string","description":"Start time in HH:MM format"},"end":{"type":"string","description":"End time in HH:MM format"}}}}}}},"CancellationRequestImage":{"type":"object","description":"Image attached to a cancellation request","properties":{"pk":{"type":"integer"},"cancellation_request":{"type":"integer","description":"Parent cancellation request ID"},"image":{"type":"string","format":"uri","description":"URL to the uploaded image"},"description":{"type":["string","null"],"description":"Optional description for the image"},"is_uploaded_by_user":{"type":"boolean","description":"Whether image was uploaded by user (vs system/admin)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"EasyReturnShippingCompany":{"type":"object","description":"Easy return shipping company option","properties":{"pk":{"type":"integer","description":"Shipping company ID"},"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"name":{"type":"string","description":"Shipping company name"}}},"DiscountItem":{"type":"object","description":"Discount applied to an order.","properties":{"name":{"type":"string","description":"Discount name/label"},"amount":{"type":"string","description":"Discount amount"},"created_date":{"type":"string","format":"date-time","description":"When discount was created"},"order_number":{"type":"string","description":"Order number this discount applies to"},"currency":{"$ref":"#/components/schemas/EnumValue"}}},"LoyaltyTransaction":{"type":"object","description":"Loyalty points transaction associated with an order.","properties":{"pk":{"type":"integer","description":"Transaction ID"},"uuid":{"type":"string","format":"uuid","description":"Unique transaction identifier"},"amount":{"type":"string","description":"Loyalty points amount"},"order":{"type":["integer","null"],"description":"Associated order ID"},"user":{"type":["integer","null"],"description":"Associated user ID"},"user_email":{"type":["string","null"],"format":"email","description":"User email for transaction"},"reference":{"type":["string","null"],"description":"Transaction reference"}}}}},"paths":{"/users/orders/":{"get":{"tags":["Orders"],"operationId":"listUserOrders","summary":"List authenticated user's orders","description":"Retrieves paginated list of orders for the authenticated user.\nIncludes order items, discounts, addresses, and payment details.\n\nFor guest users, returns only the most recent order.\n\nSupports filtering and search by order number.","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"name":"last_month","in":"query","required":false,"schema":{"type":"boolean"},"description":"Filter orders from last 30 days only"},{"name":"search","in":"query","required":false,"schema":{"type":"string"},"description":"Search by order number"},{"name":"page","in":"query","required":false,"schema":{"type":"integer"},"description":"Page number for pagination"}],"responses":{"200":{"description":"List of orders","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer"},"next":{"type":["string","null"]},"previous":{"type":["string","null"]},"results":{"type":"array","items":{"$ref":"#/components/schemas/UserOrder"}}}}}}},"401":{"description":"Authentication required"},"403":{"description":"Login required (redirects to login page)"}}}}}}
```

## Retrieve specific order details

> Retrieves detailed information for a specific order.\
> User can only access their own orders.\
> \
> \*\*Guest User Behavior:\*\*\
> For guest users, this endpoint ignores the \`pk\` parameter and always\
> returns their most recent order (ordered by \`-pk\`, first result).\
> This is because guest users are restricted to viewing only their\
> latest order.\
> \
> \*\*Access Control:\*\*\
> Users cannot access orders belonging to other users. Attempting to\
> access another user's order returns 404 Not Found.\
> \
> \*\*Response Format:\*\*\
> \- JSON requests: Returns order data directly\
> \- HTML requests: Wraps response in \`{"data": {...}}\` format

```json
{"openapi":"3.1.0","info":{"title":"Users API - Authentication, Password, Orders, and Hooks","version":"1.0.0"},"tags":[{"name":"Orders","description":"User order retrieval and cancellation"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"cookie","name":"sessionid","description":"Session cookie for authentication"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"schema":{"type":"string"},"description":"Session cookie in format `sessionid=<value>`.\nMay use site-specific cookie name (e.g., `osessionid`)."}},"schemas":{"UserOrder":{"type":"object","description":"User order with all related data including items, discounts, addresses, and payment details.","properties":{"pk":{"type":"integer","description":"Order ID"},"number":{"type":"string","description":"Order number (unique identifier)"},"status":{"$ref":"#/components/schemas/EnumValue"},"currency":{"$ref":"#/components/schemas/EnumValue"},"amount":{"type":"string","description":"Order total amount"},"discount_amount":{"type":"string","description":"Total discount applied"},"amount_without_discount":{"type":"string","description":"Amount before discounts (computed field)"},"shipping_amount":{"type":"string","description":"Shipping cost"},"shipping_tax_rate":{"type":["string","null"],"description":"Tax rate for shipping"},"refund_amount":{"type":"string","description":"Total refund amount"},"discount_refund_amount":{"type":"string","description":"Refunded discount amount"},"shipping_refund_amount":{"type":"string","description":"Refunded shipping amount"},"is_cancelled":{"type":"boolean","description":"Whether order is fully cancelled"},"is_cancellable":{"type":"boolean","description":"Whether order can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether order is eligible for refund"},"is_payable":{"type":"boolean","description":"Whether order has pending payment"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"order_type":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}],"description":"Type of order. Possible values:\n- `regular`: Standard order placed by customer\n- `addon`: Additional items added to an existing order\n- `replacement`: Replacement order for defective/incorrect items\n\nField can be null for legacy orders created before order_type was introduced."},"user_email":{"type":"string","format":"email","description":"Email address used for order"},"has_gift_box":{"type":["boolean","null"],"description":"Whether order includes gift box"},"gift_box_note":{"type":["string","null"],"description":"Gift box message/note"},"notes":{"type":["string","null"],"description":"Order delivery instructions"},"installment_count":{"type":"integer","description":"Number of payment installments"},"installment_interest_amount":{"type":"string","description":"Interest amount for installment payment"},"bin_number":{"type":["string","null"],"description":"Credit card BIN number (first 6-8 digits)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"},"shipping_address":{"$ref":"#/components/schemas/Address"},"billing_address":{"$ref":"#/components/schemas/Address"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"client_type":{"$ref":"#/components/schemas/EnumValue"},"payment_option":{"$ref":"#/components/schemas/PaymentOptionSummary"},"bank":{"oneOf":[{"$ref":"#/components/schemas/BankSummary"},{"type":"null"}],"description":"Bank information (null if not credit card payment)"},"extra_field":{"type":["object","null"],"description":"Additional order data (rewards, custom fields, etc.)"},"orderitem_set":{"type":"array","items":{"$ref":"#/components/schemas/UserOrderItem"}},"discountitem_set":{"type":"array","items":{"$ref":"#/components/schemas/DiscountItem"}},"loyaltytransaction_set":{"type":"array","items":{"$ref":"#/components/schemas/LoyaltyTransaction"}}}},"EnumValue":{"type":"object","description":"Enum representation with value and label","properties":{"value":{"type":"string","description":"Enum internal value"},"label":{"type":"string","description":"Human-readable label"}}},"Address":{"type":"object","description":"Address details with location references","properties":{"pk":{"type":"integer"},"email":{"type":["string","null"],"format":"email"},"phone_number":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"country":{"$ref":"#/components/schemas/LocationSummary"},"city":{"$ref":"#/components/schemas/LocationSummary"},"line":{"type":"string","description":"Full address line"},"title":{"type":"string","description":"Address title/label"},"township":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"district":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"postcode":{"type":["string","null"]},"notes":{"type":["string","null"],"description":"Additional delivery instructions"},"company_name":{"type":["string","null"],"description":"Company name for corporate addresses"},"tax_office":{"type":["string","null"]},"tax_no":{"type":["string","null"]},"e_bill_taxpayer":{"type":["boolean","null"],"description":"E-bill taxpayer status"},"hash_data":{"type":"string","description":"Address hash for deduplication"},"address_type":{"$ref":"#/components/schemas/EnumValue"},"retail_store":{"oneOf":[{"type":"object","description":"Retail store details for store pickup addresses"},{"type":"null"}]},"remote_id":{"type":["string","null"],"description":"Remote system identifier"},"identity_number":{"type":["string","null"],"description":"Identity/tax number"},"extra_field":{"type":["object","null"],"description":"Additional custom fields"},"user":{"type":["integer","null"],"description":"User ID who owns this address"},"is_corporate":{"type":["boolean","null"],"description":"Whether this is a corporate address"},"primary":{"type":["boolean","null"],"description":"Whether this is the primary address"}}},"LocationSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"code":{"type":"string"}}},"PaymentOptionSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"payment_type":{"type":"string"},"slug":{"type":"string"}}},"BankSummary":{"type":"object","description":"Bank information for payment","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"],"format":"uri","description":"Bank logo image URL"},"logo_path":{"type":["string","null"],"description":"Alternative path for bank logo"}}},"UserOrderItem":{"type":"object","description":"Order item within an order. Includes product details, pricing, status, and cancellation information.","properties":{"pk":{"type":"integer","description":"Order item ID"},"product":{"$ref":"#/components/schemas/UserOrderProduct"},"order":{"type":"integer","description":"Parent order ID"},"price":{"type":"string","description":"Total price for this order item"},"tax_rate":{"type":"string","description":"Tax rate applied"},"retail_price":{"type":["string","null"],"description":"Original retail price before discounts"},"discount_amount":{"type":["string","null"],"description":"Discount applied to this item"},"discounted_price":{"type":"string","description":"Final price after discount (computed field)"},"status":{"$ref":"#/components/schemas/EnumValue"},"price_currency":{"$ref":"#/components/schemas/EnumValue"},"is_cancelled":{"type":"boolean","description":"Whether item is cancelled"},"is_cancellable":{"type":"boolean","description":"Whether item can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether item is eligible for refund"},"is_tradable":{"type":"boolean","description":"Whether item is eligible for trade-in"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL for this item"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number for this item"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"shipping_option_group":{"oneOf":[{"$ref":"#/components/schemas/ShippingOptionGroup"},{"type":"null"}]},"estimated_delivery_date":{"type":["string","null"],"format":"date","description":"Estimated delivery date"},"shipped_date":{"type":["string","null"],"format":"date-time","description":"Date when item was shipped"},"delivered_date":{"type":["string","null"],"format":"date-time","description":"Date when item was delivered"},"image":{"type":["string","null"],"format":"uri","description":"Order item image (may differ from product image)"},"attributes":{"type":["object","null"],"description":"Item-specific attributes (e.g., trade-in inquiry data)"},"attributes_kwargs":{"type":["object","null"],"description":"Attribute configuration parameters"},"extra_field":{"type":["object","null"],"description":"Additional item data"},"cancellationrequest_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequest"}},"active_cancellation_request":{"oneOf":[{"$ref":"#/components/schemas/CancellationRequest"},{"type":"null"}],"description":"Most recent active cancellation request if exists"},"available_easy_return_shipping_companies":{"type":"array","items":{"$ref":"#/components/schemas/EasyReturnShippingCompany"},"description":"Available shipping companies for easy return"},"datasource_detailed":{"type":["object","null"],"description":"Data source information (if applicable)"},"extra_product_stock_detailed":{"type":["object","null"],"description":"Extra product stock details (if applicable)"},"extra_product_price_detailed":{"type":["object","null"],"description":"Extra product price details (if applicable)"}}},"UserOrderProduct":{"type":"object","description":"Product information in order context, including translations and attributes.","properties":{"pk":{"type":"integer","description":"Product ID"},"sku":{"type":"string","description":"Stock keeping unit"},"base_code":{"type":"string","description":"Product base code"},"name":{"type":"string","description":"Product name (translated)"},"image":{"type":["string","null"],"format":"uri","description":"Product image URL"},"absolute_url":{"type":"string","description":"Product detail page URL"},"attributes":{"type":"object","description":"Product attributes as key-value pairs"},"attributes_kwargs":{"type":"object","description":"Attribute configuration parameters"},"form_schema":{"type":"array","description":"Form configuration for product attributes"},"data_source":{"type":["object","null"],"description":"Data source information"},"extra_attributes":{"type":"object","description":"Additional product attributes"},"category":{"type":["object","null"],"description":"Main category information"},"attribute_set":{"type":"array","description":"Product attribute set"}}},"ShippingOptionGroup":{"type":"object","description":"Shipping option group information for order item","properties":{"pk":{"type":"integer","description":"Shipping option group ID"},"amount":{"type":"string","description":"Shipping amount"},"shipping_option_name":{"type":"string","description":"Name of shipping option"},"shipping_option_logo":{"type":["string","null"],"format":"uri","description":"Logo/icon of shipping option"}}},"CancellationRequest":{"type":"object","description":"Cancellation request record (response)","properties":{"pk":{"type":"integer"},"uuid":{"type":"string","format":"uuid","description":"Unique identifier for the cancellation request"},"order_item":{"type":"integer","description":"Order item ID"},"reason":{"type":"integer","description":"Cancellation reason ID"},"cancellation_type":{"$ref":"#/components/schemas/EnumValue"},"status":{"$ref":"#/components/schemas/EnumValue"},"description":{"type":["string","null"],"description":"User-provided cancellation description"},"iban":{"type":["string","null"],"description":"IBAN for refund (for cash payment orders)"},"holder_name":{"type":["string","null"],"description":"Account holder name for refund"},"easy_return":{"oneOf":[{"$ref":"#/components/schemas/CancellationEasyReturn"},{"type":"null"}],"description":"Easy return shipping information (for refund type cancellations)"},"quantity":{"type":["integer","null"],"description":"Quantity being cancelled (for mergeable order items)"},"fully_refund_as_loyalty_money":{"type":["boolean","null"],"description":"Whether refund is issued as loyalty points"},"cancellation_request_image_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequestImage"},"description":"Images attached to the cancellation request"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"CancellationEasyReturn":{"type":"object","description":"Easy return shipping details","properties":{"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"code":{"type":"string","description":"Easy return code/reference"},"start_date":{"type":["string","null"],"format":"date-time","description":"Pickup window start date"},"end_date":{"type":["string","null"],"format":"date-time","description":"Pickup window end date"},"status":{"$ref":"#/components/schemas/EnumValue"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"pickup_date":{"type":["object","null"],"description":"Selected pickup date and time slot","properties":{"date":{"type":"string","format":"date","description":"Pickup date in YYYY-MM-DD format"},"hour_range":{"type":"object","properties":{"start":{"type":"string","description":"Start time in HH:MM format"},"end":{"type":"string","description":"End time in HH:MM format"}}}}}}},"CancellationRequestImage":{"type":"object","description":"Image attached to a cancellation request","properties":{"pk":{"type":"integer"},"cancellation_request":{"type":"integer","description":"Parent cancellation request ID"},"image":{"type":"string","format":"uri","description":"URL to the uploaded image"},"description":{"type":["string","null"],"description":"Optional description for the image"},"is_uploaded_by_user":{"type":"boolean","description":"Whether image was uploaded by user (vs system/admin)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"EasyReturnShippingCompany":{"type":"object","description":"Easy return shipping company option","properties":{"pk":{"type":"integer","description":"Shipping company ID"},"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"name":{"type":"string","description":"Shipping company name"}}},"DiscountItem":{"type":"object","description":"Discount applied to an order.","properties":{"name":{"type":"string","description":"Discount name/label"},"amount":{"type":"string","description":"Discount amount"},"created_date":{"type":"string","format":"date-time","description":"When discount was created"},"order_number":{"type":"string","description":"Order number this discount applies to"},"currency":{"$ref":"#/components/schemas/EnumValue"}}},"LoyaltyTransaction":{"type":"object","description":"Loyalty points transaction associated with an order.","properties":{"pk":{"type":"integer","description":"Transaction ID"},"uuid":{"type":"string","format":"uuid","description":"Unique transaction identifier"},"amount":{"type":"string","description":"Loyalty points amount"},"order":{"type":["integer","null"],"description":"Associated order ID"},"user":{"type":["integer","null"],"description":"Associated user ID"},"user_email":{"type":["string","null"],"format":"email","description":"User email for transaction"},"reference":{"type":["string","null"],"description":"Transaction reference"}}}}},"paths":{"/users/orders/{pk}/":{"get":{"tags":["Orders"],"operationId":"getUserOrder","summary":"Retrieve specific order details","description":"Retrieves detailed information for a specific order.\nUser can only access their own orders.\n\n**Guest User Behavior:**\nFor guest users, this endpoint ignores the `pk` parameter and always\nreturns their most recent order (ordered by `-pk`, first result).\nThis is because guest users are restricted to viewing only their\nlatest order.\n\n**Access Control:**\nUsers cannot access orders belonging to other users. Attempting to\naccess another user's order returns 404 Not Found.\n\n**Response Format:**\n- JSON requests: Returns order data directly\n- HTML requests: Wraps response in `{\"data\": {...}}` format","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"name":"pk","in":"path","required":true,"schema":{"type":"integer"},"description":"Order ID. Must belong to the authenticated user.\nFor guest users, this parameter is ignored and the most\nrecent order is returned instead."}],"responses":{"200":{"description":"Order details retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserOrder"}}}},"401":{"description":"Authentication required"},"403":{"description":"Login required (redirects to login page)"},"404":{"description":"Order not found or doesn't belong to user.\nGuest users with no orders will also receive 404."}}}}}}
```

## Retrieve order cancellation information

> Retrieves order information relevant for cancellation.\
> Typically used to display cancellation page/form.\
> \
> \*\*Guest User Behavior:\*\*\
> For guest users, this endpoint ignores the \`pk\` parameter and always\
> returns their last order (ordered by \`-created\_date\`, last result).\
> This is because guest users are restricted to viewing only their\
> most recent order for cancellation.\
> \
> \*\*Access Control:\*\*\
> Users can only access their own orders. Attempting to access another\
> user's order returns 404 Not Found.\
> \
> \*\*Response Format:\*\*\
> \- JSON requests: Returns order data directly\
> \- HTML requests: Wraps response in \`{"data": {...}}\` format

```json
{"openapi":"3.1.0","info":{"title":"Users API - Authentication, Password, Orders, and Hooks","version":"1.0.0"},"tags":[{"name":"Orders","description":"User order retrieval and cancellation"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"cookie","name":"sessionid","description":"Session cookie for authentication"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"schema":{"type":"string"},"description":"Session cookie in format `sessionid=<value>`.\nMay use site-specific cookie name (e.g., `osessionid`)."}},"schemas":{"UserOrder":{"type":"object","description":"User order with all related data including items, discounts, addresses, and payment details.","properties":{"pk":{"type":"integer","description":"Order ID"},"number":{"type":"string","description":"Order number (unique identifier)"},"status":{"$ref":"#/components/schemas/EnumValue"},"currency":{"$ref":"#/components/schemas/EnumValue"},"amount":{"type":"string","description":"Order total amount"},"discount_amount":{"type":"string","description":"Total discount applied"},"amount_without_discount":{"type":"string","description":"Amount before discounts (computed field)"},"shipping_amount":{"type":"string","description":"Shipping cost"},"shipping_tax_rate":{"type":["string","null"],"description":"Tax rate for shipping"},"refund_amount":{"type":"string","description":"Total refund amount"},"discount_refund_amount":{"type":"string","description":"Refunded discount amount"},"shipping_refund_amount":{"type":"string","description":"Refunded shipping amount"},"is_cancelled":{"type":"boolean","description":"Whether order is fully cancelled"},"is_cancellable":{"type":"boolean","description":"Whether order can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether order is eligible for refund"},"is_payable":{"type":"boolean","description":"Whether order has pending payment"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"order_type":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}],"description":"Type of order. Possible values:\n- `regular`: Standard order placed by customer\n- `addon`: Additional items added to an existing order\n- `replacement`: Replacement order for defective/incorrect items\n\nField can be null for legacy orders created before order_type was introduced."},"user_email":{"type":"string","format":"email","description":"Email address used for order"},"has_gift_box":{"type":["boolean","null"],"description":"Whether order includes gift box"},"gift_box_note":{"type":["string","null"],"description":"Gift box message/note"},"notes":{"type":["string","null"],"description":"Order delivery instructions"},"installment_count":{"type":"integer","description":"Number of payment installments"},"installment_interest_amount":{"type":"string","description":"Interest amount for installment payment"},"bin_number":{"type":["string","null"],"description":"Credit card BIN number (first 6-8 digits)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"},"shipping_address":{"$ref":"#/components/schemas/Address"},"billing_address":{"$ref":"#/components/schemas/Address"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"client_type":{"$ref":"#/components/schemas/EnumValue"},"payment_option":{"$ref":"#/components/schemas/PaymentOptionSummary"},"bank":{"oneOf":[{"$ref":"#/components/schemas/BankSummary"},{"type":"null"}],"description":"Bank information (null if not credit card payment)"},"extra_field":{"type":["object","null"],"description":"Additional order data (rewards, custom fields, etc.)"},"orderitem_set":{"type":"array","items":{"$ref":"#/components/schemas/UserOrderItem"}},"discountitem_set":{"type":"array","items":{"$ref":"#/components/schemas/DiscountItem"}},"loyaltytransaction_set":{"type":"array","items":{"$ref":"#/components/schemas/LoyaltyTransaction"}}}},"EnumValue":{"type":"object","description":"Enum representation with value and label","properties":{"value":{"type":"string","description":"Enum internal value"},"label":{"type":"string","description":"Human-readable label"}}},"Address":{"type":"object","description":"Address details with location references","properties":{"pk":{"type":"integer"},"email":{"type":["string","null"],"format":"email"},"phone_number":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"country":{"$ref":"#/components/schemas/LocationSummary"},"city":{"$ref":"#/components/schemas/LocationSummary"},"line":{"type":"string","description":"Full address line"},"title":{"type":"string","description":"Address title/label"},"township":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"district":{"oneOf":[{"$ref":"#/components/schemas/LocationSummary"},{"type":"null"}]},"postcode":{"type":["string","null"]},"notes":{"type":["string","null"],"description":"Additional delivery instructions"},"company_name":{"type":["string","null"],"description":"Company name for corporate addresses"},"tax_office":{"type":["string","null"]},"tax_no":{"type":["string","null"]},"e_bill_taxpayer":{"type":["boolean","null"],"description":"E-bill taxpayer status"},"hash_data":{"type":"string","description":"Address hash for deduplication"},"address_type":{"$ref":"#/components/schemas/EnumValue"},"retail_store":{"oneOf":[{"type":"object","description":"Retail store details for store pickup addresses"},{"type":"null"}]},"remote_id":{"type":["string","null"],"description":"Remote system identifier"},"identity_number":{"type":["string","null"],"description":"Identity/tax number"},"extra_field":{"type":["object","null"],"description":"Additional custom fields"},"user":{"type":["integer","null"],"description":"User ID who owns this address"},"is_corporate":{"type":["boolean","null"],"description":"Whether this is a corporate address"},"primary":{"type":["boolean","null"],"description":"Whether this is the primary address"}}},"LocationSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"code":{"type":"string"}}},"PaymentOptionSummary":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"payment_type":{"type":"string"},"slug":{"type":"string"}}},"BankSummary":{"type":"object","description":"Bank information for payment","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"],"format":"uri","description":"Bank logo image URL"},"logo_path":{"type":["string","null"],"description":"Alternative path for bank logo"}}},"UserOrderItem":{"type":"object","description":"Order item within an order. Includes product details, pricing, status, and cancellation information.","properties":{"pk":{"type":"integer","description":"Order item ID"},"product":{"$ref":"#/components/schemas/UserOrderProduct"},"order":{"type":"integer","description":"Parent order ID"},"price":{"type":"string","description":"Total price for this order item"},"tax_rate":{"type":"string","description":"Tax rate applied"},"retail_price":{"type":["string","null"],"description":"Original retail price before discounts"},"discount_amount":{"type":["string","null"],"description":"Discount applied to this item"},"discounted_price":{"type":"string","description":"Final price after discount (computed field)"},"status":{"$ref":"#/components/schemas/EnumValue"},"price_currency":{"$ref":"#/components/schemas/EnumValue"},"is_cancelled":{"type":"boolean","description":"Whether item is cancelled"},"is_cancellable":{"type":"boolean","description":"Whether item can be cancelled"},"is_refundable":{"type":"boolean","description":"Whether item is eligible for refund"},"is_tradable":{"type":"boolean","description":"Whether item is eligible for trade-in"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL for this item"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"invoice_number":{"type":["string","null"],"description":"Invoice number for this item"},"invoice_date":{"type":["string","null"],"format":"date-time","description":"Invoice date"},"e_archive_url":{"type":["string","null"],"format":"uri","description":"E-Archive document URL"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"shipping_option_group":{"oneOf":[{"$ref":"#/components/schemas/ShippingOptionGroup"},{"type":"null"}]},"estimated_delivery_date":{"type":["string","null"],"format":"date","description":"Estimated delivery date"},"shipped_date":{"type":["string","null"],"format":"date-time","description":"Date when item was shipped"},"delivered_date":{"type":["string","null"],"format":"date-time","description":"Date when item was delivered"},"image":{"type":["string","null"],"format":"uri","description":"Order item image (may differ from product image)"},"attributes":{"type":["object","null"],"description":"Item-specific attributes (e.g., trade-in inquiry data)"},"attributes_kwargs":{"type":["object","null"],"description":"Attribute configuration parameters"},"extra_field":{"type":["object","null"],"description":"Additional item data"},"cancellationrequest_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequest"}},"active_cancellation_request":{"oneOf":[{"$ref":"#/components/schemas/CancellationRequest"},{"type":"null"}],"description":"Most recent active cancellation request if exists"},"available_easy_return_shipping_companies":{"type":"array","items":{"$ref":"#/components/schemas/EasyReturnShippingCompany"},"description":"Available shipping companies for easy return"},"datasource_detailed":{"type":["object","null"],"description":"Data source information (if applicable)"},"extra_product_stock_detailed":{"type":["object","null"],"description":"Extra product stock details (if applicable)"},"extra_product_price_detailed":{"type":["object","null"],"description":"Extra product price details (if applicable)"}}},"UserOrderProduct":{"type":"object","description":"Product information in order context, including translations and attributes.","properties":{"pk":{"type":"integer","description":"Product ID"},"sku":{"type":"string","description":"Stock keeping unit"},"base_code":{"type":"string","description":"Product base code"},"name":{"type":"string","description":"Product name (translated)"},"image":{"type":["string","null"],"format":"uri","description":"Product image URL"},"absolute_url":{"type":"string","description":"Product detail page URL"},"attributes":{"type":"object","description":"Product attributes as key-value pairs"},"attributes_kwargs":{"type":"object","description":"Attribute configuration parameters"},"form_schema":{"type":"array","description":"Form configuration for product attributes"},"data_source":{"type":["object","null"],"description":"Data source information"},"extra_attributes":{"type":"object","description":"Additional product attributes"},"category":{"type":["object","null"],"description":"Main category information"},"attribute_set":{"type":"array","description":"Product attribute set"}}},"ShippingOptionGroup":{"type":"object","description":"Shipping option group information for order item","properties":{"pk":{"type":"integer","description":"Shipping option group ID"},"amount":{"type":"string","description":"Shipping amount"},"shipping_option_name":{"type":"string","description":"Name of shipping option"},"shipping_option_logo":{"type":["string","null"],"format":"uri","description":"Logo/icon of shipping option"}}},"CancellationRequest":{"type":"object","description":"Cancellation request record (response)","properties":{"pk":{"type":"integer"},"uuid":{"type":"string","format":"uuid","description":"Unique identifier for the cancellation request"},"order_item":{"type":"integer","description":"Order item ID"},"reason":{"type":"integer","description":"Cancellation reason ID"},"cancellation_type":{"$ref":"#/components/schemas/EnumValue"},"status":{"$ref":"#/components/schemas/EnumValue"},"description":{"type":["string","null"],"description":"User-provided cancellation description"},"iban":{"type":["string","null"],"description":"IBAN for refund (for cash payment orders)"},"holder_name":{"type":["string","null"],"description":"Account holder name for refund"},"easy_return":{"oneOf":[{"$ref":"#/components/schemas/CancellationEasyReturn"},{"type":"null"}],"description":"Easy return shipping information (for refund type cancellations)"},"quantity":{"type":["integer","null"],"description":"Quantity being cancelled (for mergeable order items)"},"fully_refund_as_loyalty_money":{"type":["boolean","null"],"description":"Whether refund is issued as loyalty points"},"cancellation_request_image_set":{"type":"array","items":{"$ref":"#/components/schemas/CancellationRequestImage"},"description":"Images attached to the cancellation request"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"CancellationEasyReturn":{"type":"object","description":"Easy return shipping details","properties":{"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"code":{"type":"string","description":"Easy return code/reference"},"start_date":{"type":["string","null"],"format":"date-time","description":"Pickup window start date"},"end_date":{"type":["string","null"],"format":"date-time","description":"Pickup window end date"},"status":{"$ref":"#/components/schemas/EnumValue"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"tracking_url":{"type":["string","null"],"format":"uri","description":"Shipment tracking URL"},"pickup_date":{"type":["object","null"],"description":"Selected pickup date and time slot","properties":{"date":{"type":"string","format":"date","description":"Pickup date in YYYY-MM-DD format"},"hour_range":{"type":"object","properties":{"start":{"type":"string","description":"Start time in HH:MM format"},"end":{"type":"string","description":"End time in HH:MM format"}}}}}}},"CancellationRequestImage":{"type":"object","description":"Image attached to a cancellation request","properties":{"pk":{"type":"integer"},"cancellation_request":{"type":"integer","description":"Parent cancellation request ID"},"image":{"type":"string","format":"uri","description":"URL to the uploaded image"},"description":{"type":["string","null"],"description":"Optional description for the image"},"is_uploaded_by_user":{"type":"boolean","description":"Whether image was uploaded by user (vs system/admin)"},"created_date":{"type":"string","format":"date-time"},"modified_date":{"type":"string","format":"date-time"}}},"EasyReturnShippingCompany":{"type":"object","description":"Easy return shipping company option","properties":{"pk":{"type":"integer","description":"Shipping company ID"},"shipping_company":{"$ref":"#/components/schemas/EnumValue"},"name":{"type":"string","description":"Shipping company name"}}},"DiscountItem":{"type":"object","description":"Discount applied to an order.","properties":{"name":{"type":"string","description":"Discount name/label"},"amount":{"type":"string","description":"Discount amount"},"created_date":{"type":"string","format":"date-time","description":"When discount was created"},"order_number":{"type":"string","description":"Order number this discount applies to"},"currency":{"$ref":"#/components/schemas/EnumValue"}}},"LoyaltyTransaction":{"type":"object","description":"Loyalty points transaction associated with an order.","properties":{"pk":{"type":"integer","description":"Transaction ID"},"uuid":{"type":"string","format":"uuid","description":"Unique transaction identifier"},"amount":{"type":"string","description":"Loyalty points amount"},"order":{"type":["integer","null"],"description":"Associated order ID"},"user":{"type":["integer","null"],"description":"Associated user ID"},"user_email":{"type":["string","null"],"format":"email","description":"User email for transaction"},"reference":{"type":["string","null"],"description":"Transaction reference"}}}}},"paths":{"/users/orders/{pk}/cancellation/":{"get":{"tags":["Orders"],"operationId":"getOrderCancellation","summary":"Retrieve order cancellation information","description":"Retrieves order information relevant for cancellation.\nTypically used to display cancellation page/form.\n\n**Guest User Behavior:**\nFor guest users, this endpoint ignores the `pk` parameter and always\nreturns their last order (ordered by `-created_date`, last result).\nThis is because guest users are restricted to viewing only their\nmost recent order for cancellation.\n\n**Access Control:**\nUsers can only access their own orders. Attempting to access another\nuser's order returns 404 Not Found.\n\n**Response Format:**\n- JSON requests: Returns order data directly\n- HTML requests: Wraps response in `{\"data\": {...}}` format","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"name":"pk","in":"path","required":true,"schema":{"type":"integer"},"description":"Order ID. Must belong to the authenticated user.\nFor guest users, this parameter is ignored and the last\norder (by created_date) is returned instead."}],"responses":{"200":{"description":"Order cancellation details retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserOrder"}}}},"401":{"description":"Authentication required"},"403":{"description":"Login required (redirects to login page)"},"404":{"description":"Order not found or doesn't belong to user.\nGuest users with no orders will also receive 404."}}}}}}
```

## List archived/old orders

> Retrieves paginated list of archived orders.\
> These are typically migrated historical orders from legacy systems.\
> \
> \*\*Guest User Access:\*\*\
> Not available for guest users (returns empty list).\
> \
> \*\*Filtering & Search:\*\*\
> \- Currency filter: Filter by currency type (e.g., \`?currency=try\` or \`?currency=usd\`)\
> \- Number search: Search by order number using \`search\` parameter\
> \- Custom ordering: Order by any field using \`sort\` parameter

```json
{"openapi":"3.1.0","info":{"title":"Users API - Authentication, Password, Orders, and Hooks","version":"1.0.0"},"tags":[{"name":"Orders","description":"User order retrieval and cancellation"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"cookie","name":"sessionid","description":"Session cookie for authentication"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"schema":{"type":"string"},"description":"Session cookie in format `sessionid=<value>`.\nMay use site-specific cookie name (e.g., `osessionid`)."}},"schemas":{"UserOldOrder":{"type":"object","description":"Archived order from legacy systems with basic order information.","properties":{"pk":{"type":"integer"},"number":{"type":"string","description":"Order number (unique identifier)"},"user_email":{"type":"string","format":"email","description":"User email associated with order"},"status":{"type":"string","description":"Order status (stored as plain string from legacy system)"},"created_date":{"type":"string","format":"date-time"},"amount":{"type":"string","description":"Order total amount"},"discount_amount":{"type":"string","description":"Total discount applied"},"currency":{"$ref":"#/components/schemas/EnumValue"},"payment_type":{"type":["string","null"],"description":"Payment type from legacy system"},"bank":{"type":["string","null"],"description":"Bank name from legacy system"},"installment_count":{"type":"integer","description":"Number of installments"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"shipping_address":{"type":["string","null"],"description":"Shipping address (stored as plain text from legacy system)"},"billing_address":{"type":["string","null"],"description":"Billing address (stored as plain text from legacy system)"},"extra_field":{"type":"object","description":"Additional legacy data"},"oldorderitem_set":{"type":"array","items":{"$ref":"#/components/schemas/UserOldOrderItem"}}}},"EnumValue":{"type":"object","description":"Enum representation with value and label","properties":{"value":{"type":"string","description":"Enum internal value"},"label":{"type":"string","description":"Human-readable label"}}},"UserOldOrderItem":{"type":"object","description":"Item within an old/archived order","properties":{"pk":{"type":"integer"},"product":{"type":["string","null"],"description":"Product name/identifier"},"sku":{"type":["string","null"]},"quantity":{"type":["integer","null"]},"price":{"type":"string","description":"Item price"},"image":{"type":["string","null"],"format":"uri","description":"Product image URL (from uploaded image or derived from image_url)"},"image_url":{"type":["string","null"],"format":"uri","description":"Original image URL from legacy system"},"extra_field":{"type":"object","description":"Additional legacy data"}}}}},"paths":{"/users/old-orders/":{"get":{"tags":["Orders"],"operationId":"listOldOrders","summary":"List archived/old orders","description":"Retrieves paginated list of archived orders.\nThese are typically migrated historical orders from legacy systems.\n\n**Guest User Access:**\nNot available for guest users (returns empty list).\n\n**Filtering & Search:**\n- Currency filter: Filter by currency type (e.g., `?currency=try` or `?currency=usd`)\n- Number search: Search by order number using `search` parameter\n- Custom ordering: Order by any field using `sort` parameter","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"name":"currency","in":"query","required":false,"schema":{"type":"string","enum":["try","usd","eur","gbp","sar","aed","kwd","qar","bhd","omr","jod"]},"description":"Filter orders by currency type"},{"name":"search","in":"query","required":false,"schema":{"type":"string"},"description":"Search by order number"},{"name":"sort","in":"query","required":false,"schema":{"type":"string"},"description":"Field to order by.\nUse `-` prefix for descending order.\nExamples: `created_date`, `-created_date`, `amount`, `-number`\nAvailable fields: number, user_email, status, created_date, amount,\ndiscount_amount, currency, payment_type, bank, installment_count,\ntracking_number, shipping_company, shipping_address, billing_address"},{"name":"page","in":"query","required":false,"schema":{"type":"integer"},"description":"Page number for pagination"}],"responses":{"200":{"description":"List of old orders retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer"},"next":{"type":["string","null"]},"previous":{"type":["string","null"]},"results":{"type":"array","items":{"$ref":"#/components/schemas/UserOldOrder"}}}}}}},"401":{"description":"Authentication required"},"403":{"description":"Login required (redirects to login page)"}}}}}}
```

## Retrieve specific old order details

> Retrieves detailed information for a specific archived order.\
> User can only access their own orders.\
> \
> \*\*Guest User Access:\*\*\
> Not available for guest users, returns 404 Not Found for any pk value.\
> \
> \*\*Access Control:\*\*\
> Users cannot access orders belonging to other users. Attempting to\
> access another user's order returns 404 Not Found.\
> \
> \*\*Response Format:\*\*\
> \- JSON requests: Returns order data directly\
> \- HTML requests: Wraps response in \`{"data": {...}}\` format

```json
{"openapi":"3.1.0","info":{"title":"Users API - Authentication, Password, Orders, and Hooks","version":"1.0.0"},"tags":[{"name":"Orders","description":"User order retrieval and cancellation"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"cookie","name":"sessionid","description":"Session cookie for authentication"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"schema":{"type":"string"},"description":"Session cookie in format `sessionid=<value>`.\nMay use site-specific cookie name (e.g., `osessionid`)."}},"schemas":{"UserOldOrder":{"type":"object","description":"Archived order from legacy systems with basic order information.","properties":{"pk":{"type":"integer"},"number":{"type":"string","description":"Order number (unique identifier)"},"user_email":{"type":"string","format":"email","description":"User email associated with order"},"status":{"type":"string","description":"Order status (stored as plain string from legacy system)"},"created_date":{"type":"string","format":"date-time"},"amount":{"type":"string","description":"Order total amount"},"discount_amount":{"type":"string","description":"Total discount applied"},"currency":{"$ref":"#/components/schemas/EnumValue"},"payment_type":{"type":["string","null"],"description":"Payment type from legacy system"},"bank":{"type":["string","null"],"description":"Bank name from legacy system"},"installment_count":{"type":"integer","description":"Number of installments"},"tracking_number":{"type":["string","null"],"description":"Shipment tracking number"},"shipping_company":{"oneOf":[{"$ref":"#/components/schemas/EnumValue"},{"type":"null"}]},"shipping_address":{"type":["string","null"],"description":"Shipping address (stored as plain text from legacy system)"},"billing_address":{"type":["string","null"],"description":"Billing address (stored as plain text from legacy system)"},"extra_field":{"type":"object","description":"Additional legacy data"},"oldorderitem_set":{"type":"array","items":{"$ref":"#/components/schemas/UserOldOrderItem"}}}},"EnumValue":{"type":"object","description":"Enum representation with value and label","properties":{"value":{"type":"string","description":"Enum internal value"},"label":{"type":"string","description":"Human-readable label"}}},"UserOldOrderItem":{"type":"object","description":"Item within an old/archived order","properties":{"pk":{"type":"integer"},"product":{"type":["string","null"],"description":"Product name/identifier"},"sku":{"type":["string","null"]},"quantity":{"type":["integer","null"]},"price":{"type":"string","description":"Item price"},"image":{"type":["string","null"],"format":"uri","description":"Product image URL (from uploaded image or derived from image_url)"},"image_url":{"type":["string","null"],"format":"uri","description":"Original image URL from legacy system"},"extra_field":{"type":"object","description":"Additional legacy data"}}}}},"paths":{"/users/old-orders/{pk}/":{"get":{"tags":["Orders"],"operationId":"getOldOrder","summary":"Retrieve specific old order details","description":"Retrieves detailed information for a specific archived order.\nUser can only access their own orders.\n\n**Guest User Access:**\nNot available for guest users, returns 404 Not Found for any pk value.\n\n**Access Control:**\nUsers cannot access orders belonging to other users. Attempting to\naccess another user's order returns 404 Not Found.\n\n**Response Format:**\n- JSON requests: Returns order data directly\n- HTML requests: Wraps response in `{\"data\": {...}}` format","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"name":"pk","in":"path","required":true,"schema":{"type":"integer"},"description":"Old order ID. Must belong to the authenticated user.\nGuest users will always receive 404."}],"responses":{"200":{"description":"Old order details retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserOldOrder"}}}},"401":{"description":"Authentication required"},"403":{"description":"Login required (redirects to login page)"},"404":{"description":"Order not found or doesn't belong to user.\nGuest users always receive 404 for this endpoint."}}}}}}
```


---

# Agent Instructions: 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:

```
GET https://apidocs.akinon.com/commerce-openapis/users/module-3/orders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
