@stackend/api
Version:
JS bindings to api.stackend.com
24 lines • 2.46 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var moneyV2Query_1 = __importDefault(require("./moneyV2Query"));
var shippingAddressQuery_1 = __importDefault(require("./shippingAddressQuery"));
var fullProductQuery_1 = __importDefault(require("./fullProductQuery"));
/**
* Note: the query for shipping rates will fail if address is not already set
* @param getShippingRates
* @param getProductData
* @param imageMaxWidth
* @returns {string}
*/
function checkoutQuery(getShippingRates, getProductData, imageMaxWidth) {
var x = "\n id,\n webUrl,\n completedAt,\n orderStatusUrl,\n requiresShipping,\n currencyCode,\n email,\n note,\n lineItemsSubtotalPrice ".concat((0, moneyV2Query_1.default)(), ",\n subtotalPrice ").concat((0, moneyV2Query_1.default)(), ",\n subtotalPriceV2: subtotalPrice ").concat((0, moneyV2Query_1.default)(), ",\n totalPrice ").concat((0, moneyV2Query_1.default)(), ",\n totalPriceV2: totalPrice ").concat((0, moneyV2Query_1.default)(), ",\n totalTax ").concat((0, moneyV2Query_1.default)(), ",\n totalTaxV2: totalTax ").concat((0, moneyV2Query_1.default)(), ",\n taxesIncluded,\n paymentDue ").concat((0, moneyV2Query_1.default)(), ",\n paymentDueV2: paymentDue ").concat((0, moneyV2Query_1.default)(), ",\n shippingAddress {\n ").concat((0, shippingAddressQuery_1.default)(), "\n },\n shippingLine {\n title,\n handle,\n price ").concat((0, moneyV2Query_1.default)(), ",\n priceV2: price ").concat((0, moneyV2Query_1.default)(), "\n },\n lineItems(first: 100) {\n edges {\n node {\n title,\n quantity,\n discountAllocations {\n allocatedAmount ").concat((0, moneyV2Query_1.default)(), "\n },\n variant {\n product {\n ").concat(getProductData ? (0, fullProductQuery_1.default)(imageMaxWidth, true) : 'handle', "\n }\n }\n }\n }\n }");
if (getShippingRates) {
x += ",\n availableShippingRates {\n ready,\n shippingRates {\n title,\n handle,\n price: ".concat((0, moneyV2Query_1.default)(), ",\n priceV2: price ").concat((0, moneyV2Query_1.default)(), "\n }\n }");
}
return x;
}
exports.default = checkoutQuery;
//# sourceMappingURL=checkoutQuery.js.map