UNPKG

mdl-shoplet-js

Version:

JavaScript client SDK for the headless micro CRM, Minddale.

92 lines (48 loc) 2.46 kB
![Minddale](https://storage.googleapis.com/fcx-logos/minddale/Mindale-dark-tagline.png "Building digitally immortal brands!") # Minddale [Minddale](https://minddale.com) is a headless micro CRM provided by [Firecodex](https://firecodex.com) to help you build your brands digitally immortal! ## Library This mdl-shoplet-js (v1) is a JavaScript client library for Minddale, i.e. an npm library to get your JavaScript client connected to the platform and get the services done. The Shoplet module provides shopping cart functionality, allowing you to add and remove items from a cart efficiently. ## Setup This library is a very simple module added to your JavaScript project to use the service. ### Install Run `cd your-app` & `npm i mdl-shoplet-js --save` ### Use Once registered with Minddale, get your API Key generated for a particular service to connect with the platform. > Note: Make sure you keep the API Key securely in environment file or any other secure methods. In case you are not making the request from your registered domain (website), make sure you are setting the registered client domain as well in the request header `x-mdl-domain`. In order to manage shopping cart operations and inventory, use the service methods as follows. The payload for adding items to the cart should include detailed product information as shown below. ``` // Setup Dependency & API Key const mdl = require('mdl-shoplet-js'); require('dotenv').config(); const API_KEY = process.env.MDL_API_KEY; // Add Item to Cart const shopletItem = { categoryName: "Electronics", categoryCode: "ELEC", name: "Wireless Headphones", code: "12345", description: "High-quality wireless headphones with noise cancellation", tax: 5.00, minQty: 1, maxQty: 5, attributeName: "", attributeCode: "", variantName: "", variantCode: "", image: "https://example.com/headphones.jpg", price: 99.99, discount: 10.00 }; const addResponse = mdl.shoplet.addCartItem(shopletItem, API_KEY); addResponse.then(resp => console.log(resp)); // Remove Item from Cart let itemId = "item-67890"; const removeResponse = mdl.shoplet.removeCartItem(itemId, API_KEY); removeResponse.then(resp => console.log(resp)); ``` ## Support We, at Firecodex, would like to support anybody with queries or suggestions. Please feel free to reach out to us: > support@minddale.com Happy Coding!