diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b258e78
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+/mpp-sc.txt
+/bower_components
+/node_modules/
+/vendor/
+coverage
+.DS_Store
+
+# IDE Files
+#-------------------------
+/nbproject/
+/nbproject/private/
+.idea/*
+.vscode/*
+.tmp
+## Sublime Text cache files
+*.tmlanguage.cache
+*.tmPreferences.cache
+*.stTheme.cache
+*.sublime-workspace
+*.sublime-project
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..934c354
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,52 @@
+# Automatically ignored per:
+# https://www.npmjs.org/doc/developers.html#Keeping-files-out-of-your-package
+#
+# .*.swp
+# ._*
+# .DS_Store
+# .git
+# .hg
+# .lock-wscript
+# .svn
+# .wafpickle-*
+# CVS
+# npm-debug.log
+# node_modules
+
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+*.orig
+*.jql.js
+
+work
+build
+src
+test
+spec
+pids
+logs
+results
+coverage
+lib-cov
+html-report
+xunit.xml
+
+.project
+.idea
+.settings
+.iml
+*.sublime-workspace
+*.sublime-project
+
+ehthumbs.db
+Icon?
+Thumbs.db
+.AppleDouble
+.LSOverride
+.Spotlight-V100
+.Trashes
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2197832
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - "node"
diff --git a/LICENSE b/LICENSE
index 31ebdf7..dedcd21 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2016 Dipu Raj
+Copyright (c) 2017 Dipu Raj
http://www.techlaboratory.net
Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/README.md b/README.md
index 5ff0e8b..dc097a6 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# SmartCart v3-Alpha1
-#### The best jQuery shopping cart plugin with Bootstrap support.
+# SmartCart v3-Alpha
+#### The awesome jQuery Shopping Cart Plugin with PayPal payment support.
> Notice:- This is an alpha release for preview and tests, some or many functionalities may not work as expected.
> Usage on production environment is not recommended unless tested well.
@@ -17,7 +17,7 @@ Requirements
Version
-----
-**SmartCart v3-Alpha1**
+**SmartCart v3-Alpha2**
License
----
diff --git a/dist/css/smart_cart.css b/dist/css/smart_cart.css
new file mode 100644
index 0000000..e6a72a1
--- /dev/null
+++ b/dist/css/smart_cart.css
@@ -0,0 +1,154 @@
+/*!
+ * jQuery SmartCart v3.x
+ * The awesome jQuery Shopping Cart Plugin with PayPal payment support
+ * http://www.techlaboratory.net/smartcart
+ *
+ * Created by Dipu Raj
+ * http://dipuraj.me
+ *
+ * Licensed under the terms of the MIT License
+ * https://github.com/techlab/SmartCart/blob/master/LICENSE
+ */
+
+.sc-cart-item-list {
+ min-height: 50px;
+}
+
+.sc-cart-remove {
+ background: transparent;
+ border: none;
+ font-size: 20px;
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+.sc-cart-remove:hover {
+ color: red;
+}
+
+.sc-cart-empty-msg {
+ color: #999;
+ margin: 0;
+ padding: 10px;
+ text-align: center;
+}
+
+.sc-cart-item-qty {
+ width: 55px;
+ border-radius: 3px;
+ font-size: 12px;
+ padding: 4px 0 3px 6px;
+ color: #555;
+ background-color: #fff;
+ background-image: none;
+ border: 1px solid #ccc;
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ -webkit-transition: border-color 0.15s ease-in-out 0s, -webkit-box-shadow 0.15s ease-in-out 0s;
+ transition: border-color 0.15s ease-in-out 0s, -webkit-box-shadow 0.15s ease-in-out 0s;
+ transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
+ transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s, -webkit-box-shadow 0.15s ease-in-out 0s;
+}
+
+.sc-cart-item-summary {
+ text-align: right;
+ /*border-top: 1px solid #eeeeee;*/
+ margin-top: 5px;
+ padding-top: 5px;
+}
+
+.sc-cart-summary {
+ text-align: right;
+ font-size: 1.5em;
+ /*font-weight: 400;*/;
+}
+
+.sc-cart-subtotal {
+}
+
+.sc-cart-toolbar {
+ text-align: right;
+}
+
+.sc-cart-item img {
+ margin-right: 10px;
+ width: 60px;
+}
+
+.sc-highlight {
+ -webkit-animation: highlight 1s;
+ animation: highlight 1s;
+}
+
+@keyframes highlight {
+ from {
+ background: #faebcc;
+ }
+
+ to {
+ background: none;
+ }
+}
+
+@-webkit-keyframes highlight {
+ from {
+ background: #faebcc;
+ }
+
+ to {
+ background: none;
+ }
+}
+
+.sc-product-item {
+ position: relative;
+}
+
+.sc-product-item:after, .sc-product-item:before {
+ -webkit-transition: all 0.2s ease-in-out 0s;
+ transition: all 0.2s ease-in-out 0s;
+}
+
+.sc-added-item {
+ border-color: #5cb85c;
+}
+
+.sc-added-item:after {
+ content: "\2713 ";
+ display: inline-block;
+ position: absolute;
+ top: 0;
+ right: 4px;
+ z-index: 99;
+ color: #fff;
+ font-size: 18px;
+ font-weight: bold;
+ white-space: nowrap;
+}
+
+.sc-added-item:before {
+ content: "";
+ display: inline-block;
+ position: absolute;
+ z-index: 98;
+ top: 0;
+ right: 0;
+ border-style: solid;
+ border-width: 0 40px 40px 0;
+ -webkit-transform: rotate(360deg);
+ -ms-transform: rotate(360deg);
+ transform: rotate(360deg);
+ border-color: rgba(255,255,255,0) #5cb85c rgba(255,255,255,0) rgba(255,255,255,0);
+}
+
+.sc-button-checkout-default {
+}
+
+.sc-button-checkout-paypal {
+ border: 0;
+ cursor: pointer;
+ padding: 0;
+ width: 170px;
+ height: 32px;
+}
\ No newline at end of file
diff --git a/dist/css/smart_cart.min.css b/dist/css/smart_cart.min.css
new file mode 100644
index 0000000..c6ac7e3
--- /dev/null
+++ b/dist/css/smart_cart.min.css
@@ -0,0 +1,11 @@
+/*!
+ * jQuery SmartCart v3.x
+ * The awesome jQuery Shopping Cart Plugin with PayPal payment support
+ * http://www.techlaboratory.net/smartcart
+ *
+ * Created by Dipu Raj
+ * http://dipuraj.me
+ *
+ * Licensed under the terms of the MIT License
+ * https://github.com/techlab/SmartCart/blob/master/LICENSE
+ */.sc-cart-item-list{min-height:50px}.sc-cart-remove{background:0 0;border:none;font-size:20px;position:absolute;top:0;right:0}.sc-cart-remove:hover{color:red}.sc-cart-empty-msg{color:#999;margin:0;padding:10px;text-align:center}.sc-cart-item-qty{width:55px;border-radius:3px;font-size:12px;padding:4px 0 3px 6px;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;-webkit-transition:border-color .15s ease-in-out 0s,-webkit-box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,-webkit-box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s,-webkit-box-shadow .15s ease-in-out 0s}.sc-cart-item-summary{text-align:right;margin-top:5px;padding-top:5px}.sc-cart-summary{text-align:right;font-size:1.5em}.sc-cart-toolbar{text-align:right}.sc-cart-item img{margin-right:10px;width:60px}.sc-highlight{-webkit-animation:highlight 1s;animation:highlight 1s}@keyframes highlight{from{background:#faebcc}to{background:0 0}}@-webkit-keyframes highlight{from{background:#faebcc}to{background:0 0}}.sc-product-item{position:relative}.sc-product-item:after,.sc-product-item:before{-webkit-transition:all .2s ease-in-out 0s;transition:all .2s ease-in-out 0s}.sc-added-item{border-color:#5cb85c}.sc-added-item:after{content:"\2713 ";display:inline-block;position:absolute;top:0;right:4px;z-index:99;color:#fff;font-size:18px;font-weight:700;white-space:nowrap}.sc-added-item:before{content:"";display:inline-block;position:absolute;z-index:98;top:0;right:0;border-style:solid;border-width:0 40px 40px 0;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);border-color:rgba(255,255,255,0) #5cb85c rgba(255,255,255,0) rgba(255,255,255,0)}.sc-button-checkout-paypal{border:0;cursor:pointer;padding:0;width:170px;height:32px}
\ No newline at end of file
diff --git a/dist/js/jquery.smartCart.js b/dist/js/jquery.smartCart.js
new file mode 100644
index 0000000..c2f69b0
--- /dev/null
+++ b/dist/js/jquery.smartCart.js
@@ -0,0 +1,452 @@
+/*!
+ * jQuery SmartCart v3.0.1
+ * The awesome jQuery Shopping Cart Plugin with PayPal payment support
+ * http://www.techlaboratory.net/smartcart
+ *
+ * Created by Dipu Raj
+ * http://dipuraj.me
+ *
+ * Licensed under the terms of the MIT License
+ * https://github.com/techlab/SmartCart/blob/master/LICENSE
+ */
+
+;(function ($, window, document, undefined) {
+ "use strict";
+ // Default options
+
+ var defaults = {
+ cart: [], // initial products in cart
+ resultName: 'cart_list',
+ theme: 'default', // theme for the cart, related css need to include for other than default theme
+ combineProducts: true, // combine similar products on cart
+ highlightEffect: true, // highlight effect on adding/updating product in cart
+ cartItemTemplate: '
{product_name}
{product_desc}
',
+ cartItemQtyTemplate: '{display_price} × {display_quantity} = {display_amount}',
+ productContainerSelector: '.sc-product-item',
+ productElementSelector: '*', // input, textarea, select, div, p
+ addCartSelector: '.sc-add-to-cart',
+ lang: { // Language variables
+ checkout: 'Checkout',
+ clear: 'Clear',
+ subtotal: 'Subtotal:',
+ cartRemove: '×'
+ },
+
+ submitType: 'form', // form, paypal, ajax
+ ajaxURL: '', // remoteURL
+
+ toolbarSettings: {
+ showCheckoutButton: true,
+ showClearButton: true,
+ checkoutButtonStyle: 'default', // default, paypal
+ toolbarPosition: 'bottom', // none, top, bottom, both
+ toolbarButtonPosition: 'right', // left, right
+ toolbarExtraButtons: [] // Extra buttons to show on toolbar, array of jQuery input/buttons elements
+ },
+ cartDeleteAnimation: '',
+ debug: true
+ };
+
+ // The plugin constructor
+ function SmartCart(element, options) {
+ // Merge user settings with default, recursively
+ this.options = $.extend(true, {}, defaults, options);
+ // Cart array
+ this.cart = [];
+ // Cart element
+ this.cart_element = $(element);
+ this.cart_list_element = null;
+
+ // Call initial method
+ this.init();
+ }
+
+ $.extend(SmartCart.prototype, {
+
+ init: function () {
+ // Set the elements
+ this._setElements();
+ // Add toolbar
+ this._setToolbar();
+ // Assign plugin events
+ this._setEvents();
+
+ this._hasCartChange();
+ },
+
+ // PRIVATE FUNCTIONS
+
+ _setElements: function () {
+ this.cart_list_element = $('');
+ this.cart_element.append(this.cart_list_element);
+ // Set the cart element
+ this.cart_element.addClass('panel panel-default sc-cart sc-theme-' + this.options.theme);
+ this.cart_element.append('Shopping Cart 0
');
+ this.cart_element.append('');
+ },
+ _setToolbar: function () {
+ var toolbar = $('').addClass('panel-footer');
+
+ var btnCheckout = '';
+ switch (this.options.toolbarSettings.checkoutButtonStyle) {
+ case 'paypal':
+ btnCheckout = '';
+ break;
+ default:
+ btnCheckout = ' ';
+ break;
+ }
+
+ toolbar.append('' + this.options.lang.subtotal + ' 0
');
+ toolbar.append('' + btnCheckout + '
');
+ this.cart_element.append(toolbar);
+ //this.cart_element.append(' ');
+ },
+ _setEvents: function () {
+ var mi = this;
+ // Capture add to cart button events
+ $(this.options.addCartSelector).on("click", function (e) {
+ e.preventDefault();
+ var p = mi._getProductDetails($(this));
+ p = mi._addToCart(p);
+ $(this).parents(mi.options.productContainerSelector).addClass('sc-added-item').attr('data-product-unique-key', p.unique_key);
+ });
+
+ $(this.cart_element).on("click", '.sc-cart-remove', function (e) {
+ e.preventDefault();
+ $(this).parents('.sc-cart-item').fadeOut("normal", function () {
+ mi._removeFromCart($(this).data('unique-key'));
+ $(this).remove();
+ mi._hasCartChange();
+ });
+ });
+
+ $(this.cart_element).on("change", '.sc-cart-item-qty', function (e) {
+ e.preventDefault();
+ mi._updateCartQuantity($(this).parents('.sc-cart-item').data('unique-key'), $(this).val());
+ });
+
+ $(this.cart_element).on("click", '.sc-cart-checkout', function (e) {
+ e.preventDefault();
+ mi._submitCart();
+ });
+
+ $(this.cart_element).on("click", '.sc-cart-clear', function (e) {
+ e.preventDefault();
+ $('.sc-cart-item-list > .sc-cart-item', this.cart_element).fadeOut("normal", function () {
+ $(this).remove();
+ mi._clearCart();
+ mi._hasCartChange();
+ });
+ });
+ },
+ /*
+ * Get the parameters of a product by seaching elements with name attribute/data.
+ * Product details will be return as an object
+ */
+ _getProductDetails: function (elm) {
+ var mi = this;
+ var p = {};
+ elm.parents(this.options.productContainerSelector).find(this.options.productElementSelector).each(function () {
+ if ($(this).is('[name]') === true || typeof $(this).data('name') !== typeof undefined) {
+ var key = $(this).attr('name') ? $(this).attr('name') : $(this).data('name');
+ var val = mi._getContent($(this)); // $(this).val() ? $(this).val() : $(this).text();
+ if (key && val) {
+ p[key] = val;
+ }
+ }
+ });
+ return p;
+ },
+ _addToCart: function (p) {
+ var mi = this;
+
+ if (!p.hasOwnProperty('product_price')) {
+ this._logMessage('Price is not set for the item');
+ return false;
+ }
+
+ if (!p.hasOwnProperty('unique_key')) {
+ p.unique_key = this._getUniqueKey();
+ }
+
+ if (!p.hasOwnProperty('product_quantity')) {
+ p.product_quantity = 1;
+ }
+
+ if (this.options.combineProducts) {
+ var pf = $.grep(this.cart, function (n, i) {
+ return mi._isObjectsEqual(n, p);
+ });
+ if (pf.length > 0) {
+ var idx = this.cart.indexOf(pf[0]);
+ this.cart[idx].product_quantity = this.cart[idx].product_quantity - 0 + (p.product_quantity - 0);
+ p = this.cart[idx];
+ // Trigger "itemUpdated" event
+ this._triggerEvent("itemUpdated", [p]);
+ } else {
+ this.cart.push(p);
+ // Trigger "itemAdded" event
+ this._triggerEvent("itemAdded", [p]);
+ }
+ } else {
+ this.cart.push(p);
+ // Trigger "itemAdded" event
+ this._triggerEvent("itemAdded", [p]);
+ }
+
+ this._addUpdateCartItem(p);
+ return p;
+ },
+ _removeFromCart: function (unique_key) {
+ var mi = this;
+ $.each(this.cart, function (i, n) {
+ if (n.unique_key === unique_key) {
+ var itemRemove = mi.cart[i];
+ mi.cart.splice(i, 1);
+ $('*[data-product-unique-key="' + unique_key + '"]').removeClass('sc-added-item');
+ mi._hasCartChange();
+
+ // Trigger "itemRemoved" event
+ this._triggerEvent("itemRemoved", [itemRemove]);
+ return false;
+ }
+ });
+ },
+ _clearCart: function () {
+ this.cart = [];
+ // Trigger "cartCleared" event
+ this._triggerEvent("cartCleared");
+ this._hasCartChange();
+ },
+ _updateCartQuantity: function (unique_key, qty) {
+ var mi = this;
+ var qv = this._getValidateNumber(qty);
+ $.each(this.cart, function (i, n) {
+ if (n.unique_key === unique_key) {
+ if (qv) {
+ mi.cart[i].product_quantity = qty;
+ }
+ mi._addUpdateCartItem(mi.cart[i]);
+ // Trigger "cartEmpty" event
+ this._triggerEvent("quantityUpdate", [mi.cart[i], qty]);
+ return false;
+ }
+ });
+ },
+ _addUpdateCartItem: function (p) {
+ var product_amount = (p.product_quantity - 0) * (p.product_price - 0);
+ var cartList = $('.sc-cart-item-list', this.cart_element);
+ var elmMain = cartList.find("[data-unique-key='" + p.unique_key + "']");
+ if (elmMain && elmMain.length > 0) {
+ elmMain.find(".sc-cart-item-qty").val(p.product_quantity);
+ elmMain.find(".sc-cart-item-amount").text(this._getMoneyFormatted(product_amount));
+ } else {
+ elmMain = $('').addClass('sc-cart-item list-group-item');
+ elmMain.append('');
+ elmMain.attr('data-unique-key', p.unique_key);
+
+ elmMain.append(this._formatTemplate(this.options.cartItemTemplate, p));
+
+ var itemSummary = '' + this._getMoneyFormatted(p.product_price) + '';
+ itemSummary += ' × ';
+ itemSummary += ' = ' + this._getMoneyFormatted(product_amount) + '
';
+
+ elmMain.append(itemSummary);
+ cartList.append(elmMain);
+ }
+
+ if (this.options.highlightEffect === true) {
+ elmMain.addClass('sc-highlight');
+ setTimeout(function () {
+ elmMain.removeClass('sc-highlight');
+ }, 500);
+ }
+
+ this._hasCartChange();
+ },
+ _hasCartChange: function () {
+ $('.sc-cart-count', this.cart_element).text(this.cart.length);
+ $('.sc-cart-subtotal', this.element).text('' + this._getCartSubtotal());
+
+ if (this.cart.length === 0) {
+ $('.sc-cart-item-list', this.cart_element).empty().append($('Cart is Empty!
Choose your products
'));
+ $(this.options.productContainerSelector).removeClass('sc-added-item');
+
+ // Trigger "cartEmpty" event
+ this._triggerEvent("cartEmpty");
+ } else {
+ $('.sc-cart-item-list > .sc-cart-empty-msg', this.cart_element).remove();
+ }
+ $('#' + this.options.resultName, this.cart_element).val(JSON.stringify(this.cart));
+ },
+ _getCartSubtotal: function () {
+ var mi = this;
+ var subtotal = 0;
+ $.each(this.cart, function (i, p) {
+ if (mi._getValidateNumber(p.product_price)) {
+ subtotal += (p.product_price - 0) * (p.product_quantity - 0);
+ }
+ });
+ return this._getMoneyFormatted(subtotal);
+ },
+ _submitCart: function () {
+ var mi = this;
+ var formElm = this.cart_element.parents('form');
+ if (this.options.submitType === 'ajax') {} else if (this.options.submitType === 'paypal') {
+ if (formElm.length > 0) {
+ formElm.children('.sc-paypal-input').remove();
+ // Add paypal specific fields for cart products
+ $.each(this.cart, function (i, p) {
+ var itemNumber = i + 1;
+ formElm.append('').append('').append('').append('');
+ });
+
+ formElm.submit();
+ } else {
+ this._logMessage('Form not found to submit to paypal');
+ }
+ } else {
+ if (formElm.length > 0) {
+ formElm.submit();
+ } else {
+ this._logMessage('Form not found to submit');
+ }
+ }
+ return true;
+ },
+ // HELPER FUNCTIONS
+
+ _getContent: function (elm) {
+ if (elm.is(":checkbox, :radio")) {
+ return elm.is(":checked") ? elm.val() : '';
+ } else if (elm.is("[value], select")) {
+ return elm.val();
+ } else if (elm.is("img")) {
+ return elm.attr('src');
+ } else {
+ return elm.text();
+ }
+ return '';
+ },
+ _isObjectsEqual: function (o1, o2) {
+ if (Object.getOwnPropertyNames(o1).length !== Object.getOwnPropertyNames(o2).length) {
+ return false;
+ }
+ for (var p in o1) {
+ if (p === 'unique_key' || p === 'product_quantity') {
+ continue;
+ }
+ if (typeof o1[p] === typeof undefined && typeof o2[p] === typeof undefined) {
+ continue;
+ }
+ if (o1[p] !== o2[p]) {
+ return false;
+ }
+ }
+ return true;
+ },
+ _getMoneyFormatted: function (n) {
+ n = n - 0;
+ return Number(n.toFixed(2)).toLocaleString('en-US', { style: 'currency', currency: 'USD', currencyDisplay: 'symbol' });
+ },
+ _getValueOrEmpty: function (v) {
+ return v && typeof v !== typeof undefined ? v : '';
+ },
+ _getValidateNumber: function (n) {
+ n = n - 0;
+ if (n && n > 0) {
+ return true;
+ }
+ return false;
+ },
+ _formatTemplate: function (t, o) {
+ var r = t.split("{"),
+ fs = '';
+ for (var i = 0; i < r.length; i++) {
+ var vr = r[i].substring(0, r[i].indexOf("}"));
+ if (vr.length > 0) {
+ fs += r[i].replace(vr + '}', this._getValueOrEmpty(o[vr]));
+ } else {
+ fs += r[i];
+ }
+ }
+ return fs;
+ },
+ _triggerEvent: function (name, params) {
+ // Trigger an event
+ var e = $.Event(name);
+ this.cart_element.trigger(e, params);
+ if (e.isDefaultPrevented()) {
+ return false;
+ }
+ return e.result;
+ },
+ _getUniqueKey: function () {
+ var d = new Date();
+ return d.getTime();
+ },
+ _logMessage: function (msg) {
+ if (this.options.debug !== true) {
+ return false;
+ }
+ // Log message
+ $.error(msg);
+ },
+
+ // PUBLIC FUNCTIONS
+
+ theme: function (v) {
+ if (this.options.theme === v) {
+ return false;
+ }
+ this.cart_element.removeClass('sw-theme-' + this.options.theme);
+ this.options.theme = v;
+ this.cart_element.addClass('sw-theme-' + this.options.theme);
+ // Trigger "themeChanged" event
+ this._triggerEvent("themeChanged", [this.options.theme]);
+ },
+ reset: function () {
+ // Trigger "beginReset" event
+ if (this._triggerEvent("beginReset") === false) {
+ return false;
+ }
+
+ // Reset all elements and classes
+ this.container.stop(true);
+ $(".sw-toolbar", this.cart_element).remove();
+ this.steps.removeClass();
+ this.steps.data('has-content', false);
+ this.init();
+
+ // Trigger "endReset" event
+ this._triggerEvent("endReset");
+ }
+ });
+
+ // Wrapper for the plugin
+ $.fn.smartCart = function (options) {
+ var args = arguments;
+ var instance;
+
+ if (options === undefined || typeof options === 'object') {
+ return this.each(function () {
+ if (!$.data(this, "smartCart")) {
+ $.data(this, "smartCart", new SmartCart(this, options));
+ }
+ });
+ } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
+ instance = $.data(this[0], 'smartCart');
+
+ if (options === 'destroy') {
+ $.data(this, 'smartCart', null);
+ }
+
+ if (instance instanceof SmartCart && typeof instance[options] === 'function') {
+ return instance[options].apply(instance, Array.prototype.slice.call(args, 1));
+ } else {
+ return this;
+ }
+ }
+ };
+})(jQuery, window, document);
\ No newline at end of file
diff --git a/dist/js/jquery.smartCart.min.js b/dist/js/jquery.smartCart.min.js
new file mode 100644
index 0000000..e6bbafb
--- /dev/null
+++ b/dist/js/jquery.smartCart.min.js
@@ -0,0 +1,12 @@
+/*!
+ * jQuery SmartCart v3.0.1
+ * The awesome jQuery Shopping Cart Plugin with PayPal payment support
+ * http://www.techlaboratory.net/smartcart
+ *
+ * Created by Dipu Raj
+ * http://dipuraj.me
+ *
+ * Licensed under the terms of the MIT License
+ * https://github.com/techlab/SmartCart/blob/master/LICENSE
+ */
+!function(t,e,a,i){"use strict";function s(e,a){this.options=t.extend(!0,{},n,a),this.cart=[],this.cart_element=t(e),this.cart_list_element=null,this.init()}var n={cart:[],resultName:"cart_list",theme:"default",combineProducts:!0,highlightEffect:!0,cartItemTemplate:'
{product_name}
{product_desc}
',cartItemQtyTemplate:"{display_price} × {display_quantity} = {display_amount}",productContainerSelector:".sc-product-item",productElementSelector:"*",addCartSelector:".sc-add-to-cart",lang:{checkout:"Checkout",clear:"Clear",subtotal:"Subtotal:",cartRemove:"×"},submitType:"form",ajaxURL:"",toolbarSettings:{showCheckoutButton:!0,showClearButton:!0,checkoutButtonStyle:"default",toolbarPosition:"bottom",toolbarButtonPosition:"right",toolbarExtraButtons:[]},cartDeleteAnimation:"",debug:!0};t.extend(s.prototype,{init:function(){this._setElements(),this._setToolbar(),this._setEvents(),this._hasCartChange()},_setElements:function(){this.cart_list_element=t(''),this.cart_element.append(this.cart_list_element),this.cart_element.addClass("panel panel-default sc-cart sc-theme-"+this.options.theme),this.cart_element.append('Shopping Cart 0
'),this.cart_element.append('')},_setToolbar:function(){var e=t("").addClass("panel-footer"),a="";switch(this.options.toolbarSettings.checkoutButtonStyle){case"paypal":a='';break;default:a=' "}e.append(''+this.options.lang.subtotal+' 0
'),e.append(''+a+'
"),this.cart_element.append(e)},_setEvents:function(){var e=this;t(this.options.addCartSelector).on("click",function(a){a.preventDefault();var i=e._getProductDetails(t(this));i=e._addToCart(i),t(this).parents(e.options.productContainerSelector).addClass("sc-added-item").attr("data-product-unique-key",i.unique_key)}),t(this.cart_element).on("click",".sc-cart-remove",function(a){a.preventDefault(),t(this).parents(".sc-cart-item").fadeOut("normal",function(){e._removeFromCart(t(this).data("unique-key")),t(this).remove(),e._hasCartChange()})}),t(this.cart_element).on("change",".sc-cart-item-qty",function(a){a.preventDefault(),e._updateCartQuantity(t(this).parents(".sc-cart-item").data("unique-key"),t(this).val())}),t(this.cart_element).on("click",".sc-cart-checkout",function(t){t.preventDefault(),e._submitCart()}),t(this.cart_element).on("click",".sc-cart-clear",function(a){a.preventDefault(),t(".sc-cart-item-list > .sc-cart-item",this.cart_element).fadeOut("normal",function(){t(this).remove(),e._clearCart(),e._hasCartChange()})})},_getProductDetails:function(e){var a=this,i={};return e.parents(this.options.productContainerSelector).find(this.options.productElementSelector).each(function(){if(t(this).is("[name]")===!0||void 0!==t(this).data("name")){var e=t(this).attr("name")?t(this).attr("name"):t(this).data("name"),s=a._getContent(t(this));e&&s&&(i[e]=s)}}),i},_addToCart:function(e){var a=this;if(!e.hasOwnProperty("product_price"))return this._logMessage("Price is not set for the item"),!1;if(e.hasOwnProperty("unique_key")||(e.unique_key=this._getUniqueKey()),e.hasOwnProperty("product_quantity")||(e.product_quantity=1),this.options.combineProducts){var i=t.grep(this.cart,function(t,i){return a._isObjectsEqual(t,e)});if(i.length>0){var s=this.cart.indexOf(i[0]);this.cart[s].product_quantity=this.cart[s].product_quantity-0+(e.product_quantity-0),e=this.cart[s],this._triggerEvent("itemUpdated",[e])}else this.cart.push(e),this._triggerEvent("itemAdded",[e])}else this.cart.push(e),this._triggerEvent("itemAdded",[e]);return this._addUpdateCartItem(e),e},_removeFromCart:function(e){var a=this;t.each(this.cart,function(i,s){if(s.unique_key===e){var n=a.cart[i];return a.cart.splice(i,1),t('*[data-product-unique-key="'+e+'"]').removeClass("sc-added-item"),a._hasCartChange(),this._triggerEvent("itemRemoved",[n]),!1}})},_clearCart:function(){this.cart=[],this._triggerEvent("cartCleared"),this._hasCartChange()},_updateCartQuantity:function(e,a){var i=this,s=this._getValidateNumber(a);t.each(this.cart,function(t,n){if(n.unique_key===e)return s&&(i.cart[t].product_quantity=a),i._addUpdateCartItem(i.cart[t]),this._triggerEvent("quantityUpdate",[i.cart[t],a]),!1})},_addUpdateCartItem:function(e){var a=(e.product_quantity-0)*(e.product_price-0),i=t(".sc-cart-item-list",this.cart_element),s=i.find("[data-unique-key='"+e.unique_key+"']");if(s&&s.length>0)s.find(".sc-cart-item-qty").val(e.product_quantity),s.find(".sc-cart-item-amount").text(this._getMoneyFormatted(a));else{s=t("").addClass("sc-cart-item list-group-item"),s.append('"),s.attr("data-unique-key",e.unique_key),s.append(this._formatTemplate(this.options.cartItemTemplate,e));var n=''+this._getMoneyFormatted(e.product_price)+"";n+=' × ',n+=' = '+this._getMoneyFormatted(a)+"
",s.append(n),i.append(s)}this.options.highlightEffect===!0&&(s.addClass("sc-highlight"),setTimeout(function(){s.removeClass("sc-highlight")},500)),this._hasCartChange()},_hasCartChange:function(){t(".sc-cart-count",this.cart_element).text(this.cart.length),t(".sc-cart-subtotal",this.element).text(""+this._getCartSubtotal()),0===this.cart.length?(t(".sc-cart-item-list",this.cart_element).empty().append(t('Cart is Empty!
Choose your products
')),t(this.options.productContainerSelector).removeClass("sc-added-item"),this._triggerEvent("cartEmpty")):t(".sc-cart-item-list > .sc-cart-empty-msg",this.cart_element).remove(),t("#"+this.options.resultName,this.cart_element).val(JSON.stringify(this.cart))},_getCartSubtotal:function(){var e=this,a=0;return t.each(this.cart,function(t,i){e._getValidateNumber(i.product_price)&&(a+=(i.product_price-0)*(i.product_quantity-0))}),this._getMoneyFormatted(a)},_submitCart:function(){var e=this,a=this.cart_element.parents("form");return"ajax"===this.options.submitType||("paypal"===this.options.submitType?a.length>0?(a.children(".sc-paypal-input").remove(),t.each(this.cart,function(t,i){var s=t+1;a.append('').append('').append('').append('')}),a.submit()):this._logMessage("Form not found to submit to paypal"):a.length>0?a.submit():this._logMessage("Form not found to submit")),!0},_getContent:function(t){return t.is(":checkbox, :radio")?t.is(":checked")?t.val():"":t.is("[value], select")?t.val():t.is("img")?t.attr("src"):t.text()},_isObjectsEqual:function(t,e){if(Object.getOwnPropertyNames(t).length!==Object.getOwnPropertyNames(e).length)return!1;for(var a in t)if("unique_key"!==a&&"product_quantity"!==a&&(void 0!==t[a]||void 0!==e[a])&&t[a]!==e[a])return!1;return!0},_getMoneyFormatted:function(t){return t-=0,Number(t.toFixed(2)).toLocaleString("en-US",{style:"currency",currency:"USD",currencyDisplay:"symbol"})},_getValueOrEmpty:function(t){return t&&void 0!==t?t:""},_getValidateNumber:function(t){return!!((t-=0)&&t>0)},_formatTemplate:function(t,e){for(var a=t.split("{"),i="",s=0;s0?a[s].replace(n+"}",this._getValueOrEmpty(e[n])):a[s]}return i},_triggerEvent:function(e,a){var i=t.Event(e);return this.cart_element.trigger(i,a),!i.isDefaultPrevented()&&i.result},_getUniqueKey:function(){return(new Date).getTime()},_logMessage:function(e){if(this.options.debug!==!0)return!1;t.error(e)},theme:function(t){if(this.options.theme===t)return!1;this.cart_element.removeClass("sw-theme-"+this.options.theme),this.options.theme=t,this.cart_element.addClass("sw-theme-"+this.options.theme),this._triggerEvent("themeChanged",[this.options.theme])},reset:function(){if(this._triggerEvent("beginReset")===!1)return!1;this.container.stop(!0),t(".sw-toolbar",this.cart_element).remove(),this.steps.removeClass(),this.steps.data("has-content",!1),this.init(),this._triggerEvent("endReset")}}),t.fn.smartCart=function(e){var a,i=arguments;return void 0===e||"object"==typeof e?this.each(function(){t.data(this,"smartCart")||t.data(this,"smartCart",new s(this,e))}):"string"==typeof e&&"_"!==e[0]&&"init"!==e?(a=t.data(this[0],"smartCart"),"destroy"===e&&t.data(this,"smartCart",null),a instanceof s&&"function"==typeof a[e]?a[e].apply(a,Array.prototype.slice.call(i,1)):this):void 0}}(jQuery,window,document);
\ No newline at end of file
diff --git a/examples/index.html b/examples/index.html
index 2aa0575..44f0581 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -8,27 +8,13 @@
-
-
-
-
+
-
+
-
-
-
-
-
+
@@ -243,26 +229,14 @@
Product Tittle
-
-
-
-
-
-
-
-
+
+