Signup

Generating a _ZapietID

We use _ZapietID to generate rates for a checkout method. To use the rates feature in custom implementations of Store Pickup + Delivery, you will need to get a valid _ZapietId.

Getting the _ZapietId

Note

This code will work only on versions 7.0.4 and above.

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

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';
    }
}


A
Andrew is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.