> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/checkout/shipping-and-delivery/get-attribute-based-shipping-option-selection-page-context.md).

# Get Attribute-Based Shipping Option Selection Page context

Returns available shipping options grouped by product attribute values. Products are grouped based on configured attribute keys, and each group can have different shipping options available.

This page is used when `CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE` dynamic setting is set to `AttributeBasedShippingOptionSelectionPage`.

**Preconditions**:

* Shipping address must be selected (`check_address_selected`)
* Basket must not be empty

**Attribute-Based Grouping**: Products are grouped by their **attribute VALUES** (not keys). The grouping mechanism works as follows:

1. **Rule Evaluation**: The system evaluates rules from `ATTRIBUTE_KEYS_FOR_ATTRIBUTE_BASED_SHIPPING_OPTION` setting in `sort_order` priority (lower values first). Each rule is evaluated against the shipping address using location-based conditions (country, city, township, district).
2. **First Match Wins**: The **first rule** that matches the shipping address determines which `group_attribute_key` is used for grouping. Remaining rules are ignored.
3. **Grouping by Attribute Value**: Products are then grouped by the **value** of the selected attribute key. For example, if `group_attribute_key` is `"warehouse_location"`:
   * Product A with `warehouse_location: "istanbul"` → Group: `"istanbul"`
   * Product B with `warehouse_location: "istanbul"` → Group: `"istanbul"` (same group)
   * Product C with `warehouse_location: "ankara"` → Group: `"ankara"`
4. **Missing Attributes**: Products without the specified attribute are grouped under `"None"`. A default shipping option (with `is_default=True`) typically handles these products.
5. **Multiple Attribute Keys**: If `group_attribute_key` is a list (e.g., `["brand", "category"]`), products are grouped by composite keys with semicolon separator:
   * Product with `brand: "Nike", category: "shoes"` → Group: `"Nike;shoes"`
   * Product with only `brand: "Nike"` → Group: `"Nike;None"`

**Available Rules for Rule Configuration**:

| Rule Slug          | Description                                   | Parameters                                                      |
| ------------------ | --------------------------------------------- | --------------------------------------------------------------- |
| `any-rule`         | Always matches (fallback rule)                | none                                                            |
| `country-rule`     | Matches addresses in specified countries      | `countries`: list of country IDs, `exclude`: boolean            |
| `city-rule`        | Matches addresses in specified cities         | `cities`: list of city IDs, `exclude`: boolean                  |
| `township-rule`    | Matches addresses in specified townships      | `townships`: list of township IDs, `exclude`: boolean           |
| `district-rule`    | Matches addresses in specified districts      | `districts`: list of district IDs, `exclude`: boolean           |
| `postal-code-rule` | Matches addresses with specified postal codes | `postal_codes`: list of postal code strings, `exclude`: boolean |
| `not-rule`         | Negates a child rule                          | `child`: child rule object                                      |
| `and-rule`         | All children must match                       | `children`: list of child rule objects                          |
| `or-rule`          | Any child must match                          | `children`: list of child rule objects                          |

**Configuration Example**:

```json
[
  {
    "group_attribute_key": "warehouse_location",
    "rule": {"slug": "country-rule", "countries": [1, 2], "exclude": false},
    "sort_order": 1
  },
  {
    "group_attribute_key": ["brand", "category"],
    "rule": {"slug": "city-rule", "cities": [5], "exclude": false},
    "sort_order": 2
  },
  {
    "group_attribute_key": "supplier",
    "rule": {"slug": "any-rule"},
    "sort_order": 99
  }
]
```

In this example:

* For addresses in countries 1 or 2: Products are grouped by `warehouse_location`
* For addresses in city 5 (if not in countries 1, 2): Products are grouped by `brand;category`
* For all other addresses: Products are grouped by `supplier`

**Segment Support**:

* Available shipping options can vary based on user segment
* Segment-specific pricing and availability rules are applied

**Configuration**:

* `CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE`: Must be set to `AttributeBasedShippingOptionSelectionPage`
* `ATTRIBUTE_KEYS_FOR_ATTRIBUTE_BASED_SHIPPING_OPTION`: List of attribute key configurations that define how products are grouped

**Error Handling**:

* Raises `NoAttributeBasedShippingOptionAvailable` exception if no shipping options are available for the basket and shipping address combination

````json
{"openapi":"3.1.0","info":{"title":"Overview","version":"1.0.0"},"tags":[{"name":"Shipping & Delivery","description":"# Checkout Shipping & Delivery\n\nConfigure shipping options and collect delivery preferences from your customers. These endpoints cover shipping method selection, delivery time slot selection, retail store and locker pickup, remote price calculation, delivery bags, and SMS notifications.\n\n## Authentication\n\nThese endpoints support both authenticated and anonymous sessions.\n\n- **Authenticated users**: Session cookie (`sessionid`) tracks checkout progress.\n- **Anonymous users**: Guest checkout is available when the `CAN_GUEST_PURCHASE` setting is enabled.\n## Request Format\n\nInclude the following header in all checkout requests:\n\n- **x-requested-with**: `XMLHttpRequest`\n\n## Dynamic Settings\n\nThe following settings are managed at runtime through the admin interface and do not require a server restart.\n\n### CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE\nDetermines which shipping option page is active:\n- `ShippingOptionSelectionPage` — standard shipping options\n- `DataSourceShippingOptionSelectionPage` — options grouped by supplier\n- `AttributeBasedShippingOptionSelectionPage` — options grouped by product attribute\n- `RemoteShippingOptionSelectionPage` — options fetched from an external service\n\n### ATTRIBUTE_KEYS_FOR_ATTRIBUTE_BASED_SHIPPING_OPTION\nRules that determine how basket items are grouped by product attribute when the attribute-based shipping page is active. Rules are evaluated in priority order; the first matching rule determines the grouping key.\n\n### REMOTE_SHIPPING_OPTION_PROVIDER\nExternal service configuration used when `RemoteShippingOptionSelectionPage` is active. Includes the service URL and authentication credentials.\n\n### REMOTE_DELIVERY_OPTION_PROVIDER\nExternal service configuration for fetching delivery options remotely.\n\n### CHECKOUT_RETAIL_STORE_FILTERS\nFiltering options for the retail store list. When `by_stock` is enabled, only stores with available stock for basket items are shown.\n\n### DELIVERY_BAGS_CONF\nConfiguration for the delivery bags step. Set `is_active` to `true` to include the delivery bags page. Controls bag SKU, minimum quantity, and whether the customer can specify a custom quantity.\n\n### REMOTE_PRICE_ATTRIBUTE_KEY\nProduct attribute key indicating that an item requires remote price calculation.\n\n## Static Settings\n\nThe following settings are configured in the server environment and require a restart to take effect.\n\n### AUTOSELECT_SHIPPING\nWhen enabled, if only one shipping option is available after filtering, it is selected automatically and the shipping selection page is skipped.\n\n### CHECKOUT_LIST_RETAIL_STORES\nControls whether retail stores are listed on the store selection page. When disabled, an empty list is returned.\n\n### ORDER_BARCODE_SENT_SMS_EXPIRATION_IN_SECONDS\nMinimum interval in seconds between consecutive SMS sends for the same order. Prevents repeated sends within the cooldown period. Defaults to 1800 seconds (30 minutes)."}],"servers":[{"description":"Akinon Checkout API","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com"}}}],"paths":{"/orders/checkout/?page=AttributeBasedShippingOptionSelectionPage":{"get":{"tags":["Shipping & Delivery"],"operationId":"getAttributeBasedShippingOptionSelectionPage","summary":"Get Attribute-Based Shipping Option Selection Page context","description":"Returns available shipping options grouped by product attribute values.\nProducts are grouped based on configured attribute keys, and each group\ncan have different shipping options available.\n\nThis page is used when `CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE` dynamic setting\nis set to `AttributeBasedShippingOptionSelectionPage`.\n\n**Preconditions**:\n- Shipping address must be selected (`check_address_selected`)\n- Basket must not be empty\n\n**Attribute-Based Grouping**:\nProducts are grouped by their **attribute VALUES** (not keys). The grouping mechanism works as follows:\n\n1. **Rule Evaluation**: The system evaluates rules from `ATTRIBUTE_KEYS_FOR_ATTRIBUTE_BASED_SHIPPING_OPTION`\n   setting in `sort_order` priority (lower values first). Each rule is evaluated against the\n   shipping address using location-based conditions (country, city, township, district).\n\n2. **First Match Wins**: The **first rule** that matches the shipping address determines which\n   `group_attribute_key` is used for grouping. Remaining rules are ignored.\n\n3. **Grouping by Attribute Value**: Products are then grouped by the **value** of the selected\n   attribute key. For example, if `group_attribute_key` is `\"warehouse_location\"`:\n   - Product A with `warehouse_location: \"istanbul\"` → Group: `\"istanbul\"`\n   - Product B with `warehouse_location: \"istanbul\"` → Group: `\"istanbul\"` (same group)\n   - Product C with `warehouse_location: \"ankara\"` → Group: `\"ankara\"`\n\n4. **Missing Attributes**: Products without the specified attribute are grouped under `\"None\"`.\n   A default shipping option (with `is_default=True`) typically handles these products.\n\n5. **Multiple Attribute Keys**: If `group_attribute_key` is a list (e.g., `[\"brand\", \"category\"]`),\n   products are grouped by composite keys with semicolon separator:\n   - Product with `brand: \"Nike\", category: \"shoes\"` → Group: `\"Nike;shoes\"`\n   - Product with only `brand: \"Nike\"` → Group: `\"Nike;None\"`\n\n**Available Rules for Rule Configuration**:\n| Rule Slug | Description | Parameters |\n|-----------|-------------|------------|\n| `any-rule` | Always matches (fallback rule) | none |\n| `country-rule` | Matches addresses in specified countries | `countries`: list of country IDs, `exclude`: boolean |\n| `city-rule` | Matches addresses in specified cities | `cities`: list of city IDs, `exclude`: boolean |\n| `township-rule` | Matches addresses in specified townships | `townships`: list of township IDs, `exclude`: boolean |\n| `district-rule` | Matches addresses in specified districts | `districts`: list of district IDs, `exclude`: boolean |\n| `postal-code-rule` | Matches addresses with specified postal codes | `postal_codes`: list of postal code strings, `exclude`: boolean |\n| `not-rule` | Negates a child rule | `child`: child rule object |\n| `and-rule` | All children must match | `children`: list of child rule objects |\n| `or-rule` | Any child must match | `children`: list of child rule objects |\n\n**Configuration Example**:\n```json\n[\n  {\n    \"group_attribute_key\": \"warehouse_location\",\n    \"rule\": {\"slug\": \"country-rule\", \"countries\": [1, 2], \"exclude\": false},\n    \"sort_order\": 1\n  },\n  {\n    \"group_attribute_key\": [\"brand\", \"category\"],\n    \"rule\": {\"slug\": \"city-rule\", \"cities\": [5], \"exclude\": false},\n    \"sort_order\": 2\n  },\n  {\n    \"group_attribute_key\": \"supplier\",\n    \"rule\": {\"slug\": \"any-rule\"},\n    \"sort_order\": 99\n  }\n]\n```\nIn this example:\n- For addresses in countries 1 or 2: Products are grouped by `warehouse_location`\n- For addresses in city 5 (if not in countries 1, 2): Products are grouped by `brand;category`\n- For all other addresses: Products are grouped by `supplier`\n\n**Segment Support**:\n- Available shipping options can vary based on user segment\n- Segment-specific pricing and availability rules are applied\n\n**Configuration**:\n- `CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE`: Must be set to `AttributeBasedShippingOptionSelectionPage`\n- `ATTRIBUTE_KEYS_FOR_ATTRIBUTE_BASED_SHIPPING_OPTION`: List of attribute key configurations\n  that define how products are grouped\n\n**Error Handling**:\n- Raises `NoAttributeBasedShippingOptionAvailable` exception if no shipping options\n  are available for the basket and shipping address combination","parameters":[{"$ref":"#/components/parameters/AjaxRequestHeader"},{"$ref":"#/components/parameters/SessionCookieHeader"}],"responses":{"200":{"description":"Attribute-based shipping option selection page context retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutResponse"}}}}}}}},"components":{"parameters":{"AjaxRequestHeader":{"name":"x-requested-with","in":"header","required":true,"description":"Required header for AJAX requests. Must be set to `XMLHttpRequest` for all checkout requests.","schema":{"type":"string","enum":["XMLHttpRequest"],"default":"XMLHttpRequest"}},"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"description":"Session cookie header (e.g. `sessionid=abc123` or `osessionid=<session_id>`)","schema":{"type":"string"}}},"schemas":{"CheckoutResponse":{"type":"object","properties":{"context_list":{"type":"array","items":{"$ref":"#/components/schemas/PageContext"}},"pre_order":{"$ref":"#/components/schemas/PreOrder"},"errors":{"oneOf":[{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},{"type":"null"},{"type":"array","items":{"type":"string"}}]},"template_name":{"type":"string"}}},"PageContext":{"type":"object","properties":{"page_name":{"type":"string","description":"Class name of the page (e.g., \"IndexPage\", \"AddressSelectionPage\")"},"page_slug":{"type":"string","description":"URL-friendly slug for the page"},"page_context":{"type":"object","description":"Page-specific context data","additionalProperties":true}}},"PreOrder":{"type":"object","description":"Pre-order state containing basket, addresses, shipping, payment information","properties":{"basket":{"$ref":"#/components/schemas/Basket"},"shipping_address":{"oneOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}]},"billing_address":{"oneOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}]},"shipping_option":{"oneOf":[{"$ref":"#/components/schemas/ShippingOptionDetail"},{"type":"null"}]},"billing_and_shipping_same":{"oneOf":[{"type":"boolean"},{"type":"null"}]},"payment_option":{"oneOf":[{"$ref":"#/components/schemas/PaymentOptionDetail"},{"type":"null"}]},"notifications":{"type":"array","items":{"type":"object"}},"shipping_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"total_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"unpaid_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"loyalty_money":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"currency_type_label":{"type":"string"},"installment":{"oneOf":[{"$ref":"#/components/schemas/Installment"},{"type":"null"}]},"card_info":{"oneOf":[{"type":"object","description":"Card information from BIN lookup","properties":{"bin_number":{"type":"string","description":"Card BIN (first 6-8 digits)"},"card":{"type":"object","description":"Card details from BIN database","properties":{"pk":{"type":"integer"},"name":{"type":"string","description":"Card type name (e.g., \"Visa\", \"Mastercard\")"}}}}},{"type":"null"}]},"redirect_to_three_d":{"oneOf":[{"type":"boolean"},{"type":"null"}]},"delivery_option":{"oneOf":[{"$ref":"#/components/schemas/DeliveryOption"},{"type":"null"}]},"retail_store":{"oneOf":[{"$ref":"#/components/schemas/RetailStore"},{"type":"null"}]},"funds_transfer_bank":{"oneOf":[{"$ref":"#/components/schemas/BankAccount"},{"type":"null"}]},"number":{"oneOf":[{"type":"string","description":"Pre-order/order number"},{"type":"null"}]},"order":{"oneOf":[{"type":"object","description":"Created order (after checkout completion)","properties":{"pk":{"type":"integer"},"number":{"type":"string"},"status":{"type":"string"}}},{"type":"null"}]},"payment_choice":{"oneOf":[{"$ref":"#/components/schemas/PaymentChoice"},{"type":"null"}]},"user_email":{"oneOf":[{"type":"string"},{"type":"null"}]},"phone_number":{"oneOf":[{"type":"string"},{"type":"null"}]},"user_phone_number":{"oneOf":[{"type":"string"},{"type":"null"}]},"gift_box":{"oneOf":[{"type":"object","properties":{"note":{"type":"string"},"gift_video":{"type":"boolean"},"gift_video_notification_sent":{"type":"boolean"},"price":{"type":"string"}}},{"type":"null"}]},"delivery_range":{"oneOf":[{"type":"object","properties":{"lower":{"type":"string","format":"date-time"},"upper":{"type":"string","format":"date-time"}}},{"type":"null"}]},"total_amount_with_interest":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"is_guest":{"type":"boolean"},"is_post_order":{"type":"boolean"},"data_source_shipping_options":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/DataSourceShippingOptionDetail"}},{"type":"null"}]},"attribute_based_shipping_options":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/PreOrderAttributeBasedShippingOption"}},{"type":"null"}]}}},"Basket":{"type":"object","properties":{"pk":{"type":"integer"},"total_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"Address":{"type":"object","properties":{"pk":{"type":"integer"},"email":{"type":"string"},"phone_number":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"country":{"$ref":"#/components/schemas/Country"},"city":{"$ref":"#/components/schemas/City"},"line":{"type":"string"},"title":{"type":"string"},"township":{"$ref":"#/components/schemas/Township"},"district":{"oneOf":[{"$ref":"#/components/schemas/District"},{"type":"null"}]},"postcode":{"type":"string"},"notes":{"type":"string"},"company_name":{"type":"string"},"tax_office":{"type":"string"},"tax_no":{"type":"string"},"e_bill_taxpayer":{"type":"boolean"},"is_corporate":{"type":"boolean"},"primary":{"type":"boolean"},"identity_number":{"type":"string"}}},"Country":{"type":"object","properties":{"pk":{"type":"integer"},"code":{"type":"string"},"name":{"type":"string"}}},"City":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"Township":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"District":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"ShippingOptionDetail":{"type":"object","description":"Detailed shipping option with calculated amount","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"description":{"oneOf":[{"type":"string"},{"type":"null"}]},"kwargs":{"type":"object","additionalProperties":true}}},"PaymentOptionDetail":{"type":"object","description":"Detailed payment option with type information","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"payment_type":{"type":"string","enum":["credit_card","funds_transfer","bkm_express","loyalty_money","cash_register","gpay","redirection","stored_card","masterpass","masterpass_rest","credit_payment","pay_later","saved_card","confirmation","b2b","wallet","pay_on_delivery"]},"payment_type_label":{"type":"string"}}},"Installment":{"type":"object","properties":{"pk":{"type":"integer"},"installment_count":{"type":"integer"},"label":{"type":"string"},"price_with_accrued_interest":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"monthly_price_with_accrued_interest":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"DeliveryOption":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"delivery_option_type":{"type":"string","enum":["customer","retail_store","pickup_location"]},"is_active":{"type":"boolean"}}},"RetailStore":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"erp_code":{"type":"string"},"township":{"$ref":"#/components/schemas/Township"},"click_and_collect":{"type":"boolean"},"is_active":{"type":"boolean"}}},"BankAccount":{"type":"object","description":"Bank account for funds transfer payments","properties":{"pk":{"type":"integer"},"bank_name":{"type":"string","description":"Name of the bank"},"account_holder":{"type":"string","description":"Account holder name"},"iban":{"type":"string","description":"International Bank Account Number"},"currency":{"type":"string","description":"Currency code (e.g., \"USD\", \"EUR\", \"TRY\")"},"is_active":{"type":"boolean"}}},"PaymentChoice":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"},"price":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"DataSourceShippingOptionDetail":{"type":"object","description":"Data source shipping option for multi-vendor shipping","properties":{"pk":{"type":"integer"},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"shipping_option_name":{"type":"string"},"shipping_option_logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"data_source":{"type":"object","properties":{"pk":{"type":"integer"},"title":{"type":"string"}}},"description":{"oneOf":[{"type":"string"},{"type":"null"}]}}},"PreOrderAttributeBasedShippingOption":{"type":"object","description":"Attribute-based shipping option selected for a product group","properties":{"pk":{"type":"integer"},"shipping_option_name":{"type":"string"},"shipping_option_logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"product_ids":{"type":"array","items":{"type":"integer"}},"attribute_value":{"type":"string"},"attribute_key":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}}}}}}
````


---

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

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

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

```
GET https://apidocs.akinon.com/commerce-openapis/checkout/shipping-and-delivery/get-attribute-based-shipping-option-selection-page-context.md?ask=<question>&goal=<endgoal>
```

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

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

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