Skip to main content

Data Source Shipping Options

This document provides an overview of Data Source Shipping Options and their purpose. Shipping Options are essential components on the Checkout Page, to select the shipment type for an order. Typically, an order is associated with a single shipping option.

Seller Center Commerce applications have data sources which are sellers in the system. Since each data source can support different shipping options, a new structure known as Data Source Shipping Option has been implemented. This allows users to select a data source shipping option for each data source on their basket.

Sellers on the Seller Center system can support different shipping options, which are their data source shipping options. A seller can select any of available shipping options, making the DataSourceShippingOptions available to them.

Setting the CHECKOUT_SHIPPING_OPTION_SELECTION_PAGE dynamic setting as DataSourceShippingOptionSelectionPage enables the DataSourceShippingOption selection instead of standard shipping options. Otherwise, standard shipping options will be available for the entire order.

GET List Data Source Shipping Options

This method is used to get the available data source shipping options for the current checkout.

Path: /orders/checkout/?page=DataSourceShippingOptionSelectionPage

Query Parameters

The following query parameters can be used to get a list of data source shipping options.

ParameterData TypeInDescription
pagestringqueryThe checkout page that the user makes a transaction.

Example Request

To retrieve available data source shipping options, a GET request should be sent to the /orders/checkout/?page=DataSourceShippingOptionSelectionPage endpoint.

import requests

url = "https://{commerce_url}/orders/checkout/?page=DataSourceShippingOptionSelectionPage"

payload={}
headers = {
'Accept': 'application/json',
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

Example Response (200 OK)

In a successful response with a status code of 200 OK, the API returns the requested data source shipping options in a checkout context. The response includes the whole checkout page information of the user.

ParameterData TypeDescription
data_sourceslistList of data sources on the basket.
pkintThe ID of the data source.
namestringThe name of the data source.
data_source_shipping_optionslistAvailable data source shipping options of related data sources.
pkidThe ID of the data source shipping option.
shipping_amountstringThe cost of the data source shipping option.
shipping_option_namestringThe name of the data source shipping option.
shipping_option_logourlThe URL of the image of the data source shipping option.

This example response serves as a reference to understand the structure and data format returned when retrieving available data source shipping options successfully.

{
"page_context":{
"data_sources":[
{
"pk":1,
"name":"bayram ticaret",
"data_source_shipping_options":[
{
"pk":1,
"shipping_amount":"33.00",
"shipping_option_name":"B2B",
"shipping_option_logo":null,
"data_source":{
"pk":1,
"title":"Bayram Ticaret"
}
}
]
}
]
},
"page_name":"DataSourceShippingOptionSelectionPage",
"page_slug":"datasourceshippingoptionselectionpage"
}

POST Select Data Source Shipping Options

This method is used to select data source shipping options for the data sources on the checkout.

Path: /orders/checkout/?page=DataSourceShippingOptionSelectionPage

Request Body

The following request body parameters can be used to select data source shipping options.

ParameterData TypeInRequiredDescription
data_source_shipping_optionslistbodyThe list of IDs of the selected data source shipping options.

Example Request

import requests
import json

url = "https://{commerce_url}/orders/checkout/?page=DataSourceShippingOptionSelectionPage"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = "data_source_shipping_options=[3, 4, 1]"

headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Example Response (200 OK)

In a successful response with a status code of 200 OK, the API indicates that a change has occurred on the checkout. First of all, error field must be checked. If it is null, page_context of the response contains the next page information. The set of data source shipping options is returned to the client in the pre-order using the following data structure.

{
"data_source_shipping_options":[
{
"pk":1,
"shipping_amount":"33.00",
"shipping_option_name":"B2B",
"shipping_option_logo":null,
"data_source":{
"pk":1,
"title":"Bayram Ticaret"
}
}
]
}

Example Bad Request Response (200 OK)

In an unsuccessful response with a status code of 200 but contains a non-null error field, the errors are like below.

{
"errors": {
"data_source_shipping_options": [
"Invalid pk \"1\" - object does not exist."
]
}
}
"errors":{
"data_source_shipping_options":"This field is required"
}