this.fluidbook = this.cart.fluidbook;
this.items = this.cart.getSavedData();
this.data;
+ this.loggedIn = false;
this.handleTooltips = true;
this.handleTaxes = false;
this.minQuantities = {};
this.sendCookie();
$.ajax({
- url: this.baseURL + "customer/section/load/?sections=cart&update_section_id=false",
+ url: this.baseURL + "customer/section/load/",
dataType: 'json',
cache: false,
xhrFields: {withCredentials: true},
success: function (data) {
$this.fluidbook.hideLoader();
- $this.updateCartFromData(data.cart, callback);
+ $this.updateCartFromData(data.cart, data.customer, callback);
},
});
},
- updateCartFromData: function (data, callback) {
+ updateCartFromData: function (data, customer, callback) {
this.data = data;
+ this.loggedIn = customer.websiteId !== undefined && customer.websiteId !== null;
if (this.dataok()) {
this.updateCart();
}
},
+
+ checkLoginSession: function () {
+ if (!this.loggedIn) {
+ this.fluidbook.links.triggerLinkById('login');
+ return false;
+ }
+ return true;
+ },
+
addToCart: function (ref, quantity) {
var $this = this;
+ if (!this.checkLoginSession()) {
+ return;
+ }
this.fluidbook.displayLoader();
this.getProductIDBySKU(ref, function (product_id) {
if (quantity === undefined || isNaN(quantity) || quantity < minQuantity) {
quantity = minQuantity
}
-
+
$.ajax({
url: $this.baseURL + 'checkout/cart/add',
cache: false,
},
openCart: function (p2, callback) {
+ if (!this.checkLoginSession()) {
+ callback();
+ return;
+ }
if (!this.dataok()) {
callback();
return;