inTrader
Overview
inTrader is a node shopping cart module for e-commerce integration and provides the basic web shop cart functionality for online store. Includes handling of items, currency, weight, payment methods and customer details.
To begin
-
Install it:
$ npm install inTrader --save-dev -
Require it and use:
var should = ;var cart = ;
The inTrader object consists of the following sub components,
Customer, Payment, VAT, Shipment, Currency, Items,
inTrader Functions
.invoiceNumber
Set or get the order invoice number. A initial number is set when creating the cart with the following format I-YYYYMMDDHHMM, which is the year, month, day, hour and minute the cart was initiated.
var cart = ;cart; // Will return something similar to this I-YYYMMDDHHMMcart; // Set the invoice number Invoice01
.orderNumber
Set or get the order number. A initial number is set when creating the cart with the following format O-YYYYMMDDHHMM, which is the year, month, day, hour and minute the cart was initiated.
var cart = ;cart; // Will return something similar to this O-201403282210cart; // Set the invoice number Invoice01
.baseCurrency
Set or get the cart base currency using the 'XXX' format such as EUR, USD, GBP. The base currency will be used if no currency is set when requesting item and sub total for order.
var cart = ;cart; // Set the base currency to USDcart; // fetch the base currency, 'USD' value
.orderDate
Set or get order date. The order date is a regular javascript Date Object
var cart = ;cart; // Will return the current Datecart; // Will return the order date day of the monthcart; // Will return the order date day of the weekcart; // Returns the order date year in 4 digitscart; // Set day to 20th day of monthcart; // Set the Month to the March, January is 0, February is 1, and so oncart; // Set order date to year 1999
.expiryDate
Set or get expiry date for order. The expiry date is a regular javascript Data Object to work with dates and times
var cart = ;cart; // Will return the current Datecart; // Will return the order date day of the monthcart; // Will return the order date day of the weekcart; // Returns the order date year in 4 digitscart; // Set day to 20th day of monthcart; // Set the Month to the March, January is 0, February is 1, and so oncart; // Set order date to year 1999
.currencies
Array of the different currencies used in cart
var cart = ;cart;
.items
Array of the order cart item
var cart = ;cart;
.addItem
Add item to cart
cart;
.removeItem
Remove item from cart
var cart = ;cart;cart;
.updateItem
Update cart item
var cart = ;cart;cart;
.addCurrency
Add a currency
var cart = ;cartcart;cart;cart // Item total =1.421;cart // Item total = 1.17188451;cart;cartitemTotal // item total = 1.421;cartbaseCurrency = 'GBP'; // total = 1.17188451;
.removeCurrency
Remove currency
var cart = ;cart;cart;cart;
.updateCurrency
Update a currency
var cart = ;cart;cart;cartitemTotalshouldbe = 13921;cart; //itemTotal = 15.171;
.reset
Reset cart, clear items and reset total to 0
var cart = ;cart;
.vatTotal
Return the vat total based on all the items in cart
var cart = ;cart;cart; //Set the vat rate to 25%cart // 3.125,
.itemTotal
Return the total sum of all items in cart
var cart = ;cart;cart;cart // 13.921, The first added currency will serve as base currency an it's rate will be used to calculate the total (12.5 * 1.11368);cart //13.921, Same as previous since this matches the base currency;
.subTotal
Return the sub total of cart, includes item total and fees for shipment and payment
var cart = ;cart;cartmethod'PayPal';cart;cart;carttext'How to pay with paypal';cart // 10.1;
.weight
Returns the total weigh of the cart items
var cart = ;cart;cart //120
.toJSON
Return cart in JSON format
var cart = ;cart;cartJSON = cart;console; // product_1
Customer Functions
Set and get for the following customer values, ID, firstName, lastName, customerNumber, pinNumber, address, address2, zip, city, country, countryCode, deliveryAddress, deliveryZip, deliveryCity, email, mobileNumber, company, vatNumber;
var cart = ;cart // The Customer objectcart;cart;cartshouldhave;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;
Payment Functions
Set and get for the payment functions registered, method, fee, text
var cart = ;cartmethod'PayPal';cart; //Payment has not been registeredcart;carttext'How to pay description';
Currency Functions
Set and get for the payment options code, rate, symbol
var cart = ;var currency = ;currencycode'USD';currency;currency;cart;cartlengthshould;
Shipment Functions
Set and get for the payment options method, fee, zone
var cart = ;cart;cart;cartmethod'Regular Post';
VAT Functions
.rate
Get and set for the cart VAT rate
var cart = ;cart;
Item Functions
Get and set for Item object ID, qty, price, weight, itemNumber
var cart = ;var item = ; item;item;item;item;cart;
The item can be added directly to cart if you pass the argument as a object
var cart = ;cart; #Complete Order``````jsvar cart = ; cart; // Set the vat rate to 25% //Add some items to the cartcart;cart;cart;cart;cart; cart; // 1470;cart; // 171.25;cart; // 171.25; cart;cart;cart; // 171.25cart; // 251.03 cart // 42.8125 cart; // false cart;cart;cart;cart; cart // 171.25;cart // 251.03; cart // 19.4677;cart // 16.05481782125;cart // 26.15741; cart // 28.5370904;cart // 23.53425353383;cart // 38.343326319999996; cart // 4.866925;cart // 4.0137044553125;cart // 6.5393525; cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart;cart; cart; cart;cart // false;
Feedback How to Contribute
- Fork and edit
- Submit pull request for consideration
Contribute Style Guide
- Be clear on your commit messages
- Every pull request may not be accepted. Don't blame anybody.