# Shipping Rate

{% hint style="info" %}
Shipping Rate task is available only on Advanced Shopify plan or higher.
{% endhint %}

With this task you can create your custom shipping rates returned on checkout shipping step. Task allows creating complex logic to calculate shipping rate based on:

* cart items
* shipping address
* customer (Shopify Script Editor required)

Incoming request has following format:

```
  {
    "rate": {
      "origin": {
        "country": "CA",
        "postal_code": "K2P1L4",
        "province": "ON",
        "city": "Ottawa",
        "name": null,
        "address1": "150 Elgin St.",
        "address2": "",
        "address3": null,
        "phone": "16135551212",
        "fax": null,
        "email": null,
        "address_type": null,
        "company_name": "Jamie D's Emporium"
      },
      "destination": {
        "country": "CA",
        "postal_code": "K1M1M4",
        "province": "ON",
        "city": "Ottawa",
        "name": "Bob Norman",
        "address1": "24 Sussex Dr.",
        "address2": "",
        "address3": null,
        "phone": null,
        "fax": null,
        "email": null,
        "address_type": null,
        "company_name": null
      },
      "items": [
        {
          "name": "Short Sleeve T-Shirt",
          "sku": "",
          "quantity": 1,
          "grams": 1000,
          "price": 1999,
          "vendor": "Jamie D's Emporium",
          "requires_shipping": true,
          "taxable": true,
          "fulfillment_service": "manual",
          "properties": null,
          "product_id": 48447225880,
          "variant_id": 258644705304
        }
      ],
      "currency": "USD",
      "locale": "en"
    }
  }
```

You can access this payload through `request` object:

```
{{request.body.rate | log }}
```

Above line outputs payload to logs.

You can now parse available information to calculate additional shipping rates returned on checkout shipping step.

Example response would look like this:

```
{% json response %}
  {
    "body": {
      "rates": [
        {
          "service_name": "canadapost-overnight",
          "service_code": "ON",
          "total_price": "1295",
          "description": "This is the fastest option by far",
          "currency": "CAD",
          "min_delivery_date": "2013-04-12 14:48:45 -0400",
          "max_delivery_date": "2013-04-12 14:48:45 -0400"
        }
      ]
    }
  }
{% endjson %}
```

On checkout you should see:<br>

<figure><img src="/files/lVgk6IEVFSTmDOl6u8w5" alt=""><figcaption></figcaption></figure>


---

# 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://docs.datajet-app.com/scripts/blank/shipping-rate.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.
