Code Examples

Previous Next

Open file "index.htm" located in softecartjs folder and find following lines and edit accordingly.

Set how many products you want to display on each page
In example below we set 1 product per page for mobile browsers and 5 products for web browsers: = SoftEcartJS.isMobile() ? 1 : 5;

Set your paypal email address:

SoftEcartJS.paypalEmail = "";

Set currency of shopping cart - currently following currencies are supported (USD,EUR,ILS,RUB):

SoftEcartJS.currencyCode = "USD";

Feed SoftEcartJS with array of products as each product is represented as a valid json object containing following fields:

1) ID - product ID : any unique key
2) Title - product Title
3) Description - product Description
4) Weight - product Weight in grams
5) Price - product Price without currency
6) ImageSrc - path to product's preview image
7) ImageWidth - product's preview image width
8) ImageHeight - product's preview image height
9) ImageBigSrc - path to product's large image shown when preview image clicked
10) Package - product's additional info such as it's form, shape or quantity contained in package
11) order - product's ordinal number in array

SoftEcartJS.products = [ { ID: "A01", Title: "Biocalcium "Tiens" shared dietary supplement", Description: "Is a full cellular nutrition and the prevention of more than 150 different...", Weight: "100", Price: "115.00", ImageSrc: "images/product-5.jpg", ImageWidth: "150", ImageHeight: "150", ImageBigSrc: "images/product-big-5.jpg", Package: "Product form: 10 packages х 10g", order: 1 } ];

Open file "softecartjs.js" located in js folder:

Handling shipping cost, find following code snippet and edit price of shipping according to overall weight of all ordered products (in grams) in shopping cart: The variable "a" holds weight of order in grams, there is gradation of shipping cost for every additional 500 grams, for example up to 500 grams will cost you 69.8.

getShippingCost:function(){ var a =; if (a > 0 && a <= 500) { return 69.8; } };