For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

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

get
Header parameters
x-requested-withstring · enumRequired

Required header for AJAX requests. Must be set to XMLHttpRequest for all checkout requests.

Default: XMLHttpRequestPossible values:
CookiestringOptional

Session cookie header (e.g. sessionid=abc123 or osessionid=<session_id>)

Responses
200

Attribute-based shipping option selection page context retrieved

application/json
errorsone of · nullableOptional
or
string[]Optional
template_namestringOptional
get/orders/checkout/?page=AttributeBasedShippingOptionSelectionPage
GET /orders/checkout/?page=AttributeBasedShippingOptionSelectionPage HTTP/1.1
Host: sandbox.akinon.com
x-requested-with: XMLHttpRequest
Accept: */*
200

Attribute-based shipping option selection page context retrieved

{
  "context_list": [
    {
      "page_name": "AttributeBasedShippingOptionSelectionPage",
      "page_slug": "attributebasedshippingoptionselectionpage",
      "page_context": {
        "attribute_based_shipping_options": {
          "electronics": {
            "attribute_based_shipping_options": [
              {
                "pk": 100,
                "shipping_amount": "5.99",
                "shipping_option_name": "Standard Delivery",
                "shipping_option_logo": "https://cdn.akinon.com/logos/standard.png"
              },
              {
                "pk": 101,
                "shipping_amount": "15.99",
                "shipping_option_name": "Express Delivery",
                "shipping_option_logo": "https://cdn.akinon.com/logos/express.png"
              }
            ],
            "product_ids": [
              1001,
              1002,
              1003
            ],
            "attribute_key": [
              "category"
            ]
          },
          "clothing": {
            "attribute_based_shipping_options": [
              {
                "pk": 200,
                "shipping_amount": "3.99",
                "shipping_option_name": "Economy Delivery",
                "shipping_option_logo": "https://cdn.akinon.com/logos/economy.png"
              },
              {
                "pk": 201,
                "shipping_amount": "8.99",
                "shipping_option_name": "Standard Delivery",
                "shipping_option_logo": "https://cdn.akinon.com/logos/standard.png"
              }
            ],
            "product_ids": [
              2001,
              2002
            ],
            "attribute_key": [
              "category"
            ]
          }
        }
      }
    }
  ],
  "pre_order": {
    "basket": {
      "pk": 123,
      "total_amount": "150.00"
    },
    "shipping_address": {
      "pk": 10,
      "first_name": "John",
      "last_name": "Doe",
      "email": "john@akinon.com",
      "phone_number": "+15551234567",
      "line": "123 Main St",
      "country": {
        "pk": 1,
        "code": "US",
        "name": "United States"
      },
      "city": {
        "pk": 1,
        "name": "New York"
      },
      "township": {
        "pk": 1,
        "name": "Manhattan"
      }
    },
    "billing_address": {
      "pk": 10,
      "first_name": "John",
      "last_name": "Doe"
    },
    "billing_and_shipping_same": true,
    "delivery_option": {
      "pk": 1,
      "name": "Home Delivery",
      "slug": "home-delivery",
      "delivery_option_type": "customer",
      "sort_order": 1
    },
    "shipping_option": null,
    "shipping_amount": null,
    "payment_option": null,
    "notifications": [],
    "total_amount": "150.00",
    "unpaid_amount": "150.00",
    "loyalty_money": null,
    "currency_type_label": "USD",
    "installment": null,
    "redirect_to_three_d": null,
    "retail_store": null,
    "payment_choice": null,
    "user_email": "john@akinon.com",
    "phone_number": "+15551234567",
    "user_phone_number": "+15551234567",
    "gift_box": null,
    "delivery_range": null,
    "total_amount_with_interest": "150.00",
    "is_guest": false,
    "is_post_order": false,
    "data_source_shipping_options": null,
    "attribute_based_shipping_options": null
  },
  "errors": [],
  "template_name": "orders/checkout.html"
}

Last updated

Was this helpful?