smolcart.js
Version:
a teeny tiny wrapper for Shopify's Ajax API
34 lines (33 loc) • 1.31 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCart = exports.clearCart = exports.modifyItem = exports.addItems = exports.loadPolyfills = void 0;
/* eslint-disable no-async-promise-executor */
const index_1 = require("./types/index");
const Action_1 = __importDefault(require("./Action"));
const loadPolyfills = () => {
document.write('<script src="https://polyfill.io/v3/polyfill.min.js?callback=smolPolyLoaded"></script>');
};
exports.loadPolyfills = loadPolyfills;
const addItems = (items) => {
const action = new Action_1.default(items, index_1.ActionType.Add);
return action.execute();
};
exports.addItems = addItems;
const modifyItem = (item) => {
const action = new Action_1.default([item], index_1.ActionType.Modify);
return action.execute();
};
exports.modifyItem = modifyItem;
const clearCart = () => {
const action = new Action_1.default(null, index_1.ActionType.ClearCart);
return action.execute();
};
exports.clearCart = clearCart;
const getCart = () => {
const action = new Action_1.default(null, index_1.ActionType.GetCart);
return action.execute();
};
exports.getCart = getCart;
;