# ZapietId

## What is the ZapietId?

The \_ZapietId is integral to our Rates functionality. At least one item in your customers basket must contain a valid \_ZapietId line item property otherwise rates will fail to generate correctly within the checkout process. &#x20;

![](/files/-M__wlMldQsFx5JfuImJ)

The \_ZapietId is made up of the following three parameters:

| Parameter | Data type | Example              | Notes                                                                                                                                                                   |
| --------- | --------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| M         | string    | P                    | <p>The value can be either P, D or S. </p><p></p><p>P = pickup</p><p>D = delivery</p><p>S = shipping  </p><p></p><p><strong>Required for all orders</strong></p>        |
| L         | integer   | 1002                 | <p>The Zapiet location ID </p><p></p><p><strong>Required for pickup and delivery orders</strong></p>                                                                    |
| D         | datetime  | 2021-05-13T12:00:00Z | <p>The customers selected date and time for delivery, pickup or shipping</p><p></p><p><strong>Required for date based pickup, delivery and shipping orders</strong></p> |

## Adding the \_ZapietId to a line item

If you are using our default widget the \_ZapietId property is automatically added to your order. Should you be building your own storefront widget you can use Shopify's Cart API <https://shopify.dev/docs/themes/ajax-api/reference/cart>.&#x20;

Alternatively if you are building a mobile app or using a headless commerce solution you may prefer to use the Draft Orders API <https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder>.

{% hint style="info" %}
The line item must be called \_ZapietId including the prepending underscore.&#x20;
{% endhint %}

```javascript
$.post('/cart/change.js', data);
```

## Generating the \_ZapietId

Below is a  javascript example of how you might generate a \_ZapietId.

```javascript
function getZapietId(params)
{
    var fomatted_date = '';
    if (params.date && !params.time) {
        var fomatted_date = params.date.replace(/\//g, "-");
        fomatted_date = fomatted_date + 'T00:00:00Z';
    } else if (params.date && params.start_time) {
        var fomatted_date = params.date.replace(/\//g, "-");
        fomatted_date = fomatted_date + 'T' + params.start_time + ':00Z';
    }
    return this.encodeZapietId({
        M: this.getMethodKey(params.method),
        L: (params.location_id) ? params.location_id : "",
        D: fomatted_date,
        P: ""
    });
}

function getMethodKey(method) {
    if (method == 'delivery') {
        return 'D';
    } else if (method == 'pickup') {
        return 'P';
    } else {
        return 'S';
    }
}

function encodeZapietId(params) {
    const ret = [];
    for (let d in params) {
        if (params[d]) {
            ret.push(d + '=' + params[d]);
        }
    }
    return ret.join('&');
}

const ZapietId = getZapietId({
   date: '2021-05-13',
   start_time: '10:00',
   location_id: 10001,
   method: 'pickup'
});
```


---

# 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.zapiet.com/guides/zapiet_id.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.
