diff --git a/src/Foundation.Cms/Extensions/ContentReferenceExtensions.cs b/src/Foundation.Cms/Extensions/ContentReferenceExtensions.cs
index 383d9d503..8919644a8 100644
--- a/src/Foundation.Cms/Extensions/ContentReferenceExtensions.cs
+++ b/src/Foundation.Cms/Extensions/ContentReferenceExtensions.cs
@@ -120,7 +120,19 @@ public static Uri GetUri(this ContentReference contentRef, string lang, bool isA
//Work out the correct domain to use from the hosts defined in the site definition
var siteDefinition = SiteDefinitionResolver.Value.GetByContent(contentRef, true, true);
var host = siteDefinition.Hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Primary) ?? siteDefinition.Hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Undefined);
- var baseUrl = (host?.Name ?? "*").Equals("*") ? siteDefinition.SiteUrl : new Uri($"http{((host.UseSecureConnection ?? false) ? "s" : string.Empty)}://{host.Name}");
+ Uri baseUrl;
+
+ if (host != null)
+ {
+ baseUrl = (host?.Name ?? "*").Equals("*") ? siteDefinition.SiteUrl : new Uri($"http{((host.UseSecureConnection ?? false) ? "s" : string.Empty)}://{host.Name}");
+ }
+ else
+ {
+ var siteDef = SiteDefinitionResolver.Value.GetByContent(ContentReference.StartPage, true, true);
+ var siteDefHost = siteDef.Hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Primary) ?? siteDefinition.Hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Undefined);
+ baseUrl = (siteDefHost?.Name ?? "*").Equals("*") ? siteDef.SiteUrl : new Uri($"http{((siteDefHost.UseSecureConnection ?? false) ? "s" : string.Empty)}://{siteDefHost.Name}");
+ }
+
return new Uri(baseUrl, urlString);
}
}
diff --git a/src/Foundation/Assets/js/main.js b/src/Foundation/Assets/js/main.js
index c54650d5f..5321df701 100644
--- a/src/Foundation/Assets/js/main.js
+++ b/src/Foundation/Assets/js/main.js
@@ -10,6 +10,7 @@ import FoundationCommerce from "Assets/js/common/foundation.commerce";
import FoundationPersonalization from "Assets/js/common/foundation.cms.personalization";
feather.replace();
+window.feather = feather;
let foundationCms = new FoundationCms();
foundationCms.init();
diff --git a/src/Foundation/Features/CatalogContent/product.js b/src/Foundation/Features/CatalogContent/product.js
index f702c1215..c45012648 100644
--- a/src/Foundation/Features/CatalogContent/product.js
+++ b/src/Foundation/Features/CatalogContent/product.js
@@ -1,188 +1,188 @@
export default class Product {
- constructor(divId) {
- if (divId) {
- this.divContainerId = divId;
- } else {
- this.divContainerId = document;
- }
- }
-
- init() {
- this.addToWishlistClick();
- this.addToSharedCartClick();
- this.addToCartClick();
- this.addAllToCartClick();
- this.deleteWishlistClick();
+ constructor(divId) {
+ if (divId) {
+ this.divContainerId = divId;
+ } else {
+ this.divContainerId = document;
}
-
- addToCart(data, url, callback, isAddToCart) {
- $('body>.loading-box').show();
- data.requestFrom = "axios";
- axios.post(url, data)
- .then(function (result) {
- if (result.data.StatusCode == 0) {
- notification.warning(result.data.Message);
- }
- if (result.data.StatusCode == 1) {
- let checkoutLink = "";
- let cartLink = "";
- if ($('#checkoutBtnId')) {
- checkoutLink = $('#checkoutBtnId').attr('href');
- }
-
- if ($('#cartBtnId')) {
- cartLink = $('#cartBtnId').attr('href');
- }
-
- let message = result.data.Message;
- if (isAddToCart) {
- let bottomNotification = `\n
+ }
+
+ init() {
+ this.addToWishlistClick();
+ this.addToSharedCartClick();
+ this.addToCartClick();
+ this.addAllToCartClick();
+ this.deleteWishlistClick();
+ }
+
+ addToCart(data, url, callback, isAddToCart) {
+ $('body>.loading-box').show();
+ data.requestFrom = "axios";
+ axios.post(url, data)
+ .then(function (result) {
+ if (result.data.StatusCode == 0) {
+ notification.warning(result.data.Message);
+ }
+ if (result.data.StatusCode == 1) {
+ let checkoutLink = "";
+ let cartLink = "";
+ if ($('#checkoutBtnId')) {
+ checkoutLink = $('#checkoutBtnId').attr('href');
+ }
+
+ if ($('#cartBtnId')) {
+ cartLink = $('#cartBtnId').attr('href');
+ }
+
+ let message = result.data.Message;
+ if (isAddToCart) {
+ let bottomNotification = `\n
`;
- message += bottomNotification;
- }
-
- notification.success(message, false);
-
- if (callback) callback(result.data.CountItems);
- }
- })
- .catch(function (error) {
- notification.error("Can not add the product to the cart.\n" + error.response.statusText);
- })
- .finally(function () {
- $('body>.loading-box').hide();
- });
-
- return false;
- }
-
- // use in Wishlist Page
- removeItem(data, url, message, callback) {
- $('body>.loading-box').show();
- axios.post(url, data)
- .then(function (result) {
- if (result.status == 200) {
- notification.success(message);
- $('#my-wishlist').html(result.data);
- let product = new Product('#my-wishlist');
- product.Init();
- let count = $('#countWishListInPage').val();
- if (callback) callback(count);
-
- feather.replace();
- }
- if (result.status == 204) {
- notification.error(result.statusText);
- }
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
- $('body>.loading-box').hide();
- });
- }
-
- callbackAddToCart(selector, count) {
- if (selector == ".jsCartBtn") { cartHelper.setCartReload(count); }
- else if (selector == ".jsSharedCartBtn") { cartHelper.setSharedCartReload(count)}
- else cartHelper.setWishlistReload(count);
- }
-
- addToSharedCartClick() {
- let inst = this;
- $(this.divContainerId).find('.addToSharedCart').each(function (i, e) {
- $(e).click(function () {
- let code = $(this).attr('data');
-
- let callback = (count) => {
- inst.callbackAddToCart('.jsSharedCartBtn', count);
- };
-
- inst.addToCart({ Code: code }, '/SharedCart/AddToCart', callback);
- });
- });
- }
-
- addToWishlistClick() {
- let inst = this;
-
- $(this.divContainerId).find('.addToWishlist').each(function (i, e) {
- $(e).click(function () {
- let code = $(this).attr('data');
+ message += bottomNotification;
+ }
- let callback = (count) => {
- inst.callbackAddToCart('#js-wishlist', count);
- };
+ notification.success(message, false);
- inst.addToCart({ Code: code }, '/Wishlist/AddToCart', callback);
- });
- });
-
- }
-
- addToCartClick() {
- let inst = this;
-
- $(this.divContainerId).find('.addToCart').each(function (i, e) {
- $(e).attr("href", "javascript:void(0);")
- $(e).click(function () {
- let code = $(this).attr('data');
- let data = {
- Code: code
- };
-
- if ($(this).attr('qty')) data.Quantity = $(this).attr('qty');
- if ($(this).attr('store')) data.Store = $(this).attr('store');
- if ($(this).attr('selectedStore')) data.SelectedStore = $(this).attr('selectedStore');
-
- let callback = (count) => {
- inst.callbackAddToCart('.jsCartBtn', count);
- };
-
- inst.addToCart(data, '/DefaultCart/AddToCart', callback, true);
- });
- });
- }
-
- deleteWishlistClick() {
- let inst = this;
-
- $(this.divContainerId).find('.deleteLineItemWishlist').each(function (i, e) {
- $(e).click(function () {
- if (confirm("Are you sure?")) {
- let code = $(e).attr('data');
- let data = { Code: code, Quantity: 0, RequestFrom: "axios" };
- let callback = (count) => {
- inst.callbackAddToCart("#js-wishlist", count);
- };
- inst.removeItem(data, '/Wishlist/ChangeCartItem', "Removed " + code + " from wishlist", callback);
- }
- });
- });
- }
-
- addAllToCartClick() {
- $(this.divContainerId).find('.jsAddAllToCart').each(function (i, e) {
- $(e).click(function () {
- $('.loading-box').show();
- let url = $(this).attr('url');
- axios.post(url)
- .then(function (result) {
- notification.success(result.data.Message);
- cartHelper.setCartReload(result.data.CountItems);
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
- $('.loading-box').hide();
- });
-
- });
- });
-
- }
+ if (callback) callback(result.data.CountItems);
+ }
+ })
+ .catch(function (error) {
+ notification.error("Can not add the product to the cart.\n" + error.response.statusText);
+ })
+ .finally(function () {
+ $('body>.loading-box').hide();
+ });
+
+ return false;
+ }
+
+ // use in Wishlist Page
+ removeItem(data, url, message, callback) {
+ $('body>.loading-box').show();
+ axios.post(url, data)
+ .then(function (result) {
+ if (result.status == 200) {
+ notification.success(message);
+ $('#my-wishlist').html(result.data);
+ feather.replace();
+
+ let product = new Product('#my-wishlist');
+ product.init();
+ let count = $('#countWishListInPage').val();
+ if (callback) callback(count);
+ }
+ if (result.status == 204) {
+ notification.error(result.statusText);
+ }
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $('body>.loading-box').hide();
+ });
+ }
+
+ callbackAddToCart(selector, count) {
+ if (selector == ".jsCartBtn") { cartHelper.setCartReload(count); }
+ else if (selector == ".jsSharedCartBtn") { cartHelper.setSharedCartReload(count) }
+ else cartHelper.setWishlistReload(count);
+ }
+
+ addToSharedCartClick() {
+ let inst = this;
+ $(this.divContainerId).find('.addToSharedCart').each(function (i, e) {
+ $(e).click(function () {
+ let code = $(this).attr('data');
+
+ let callback = (count) => {
+ inst.callbackAddToCart('.jsSharedCartBtn', count);
+ };
+
+ inst.addToCart({ Code: code }, '/SharedCart/AddToCart', callback);
+ });
+ });
+ }
+
+ addToWishlistClick() {
+ let inst = this;
+
+ $(this.divContainerId).find('.addToWishlist').each(function (i, e) {
+ $(e).click(function () {
+ let code = $(this).attr('data');
+
+ let callback = (count) => {
+ inst.callbackAddToCart('#js-wishlist', count);
+ };
+
+ inst.addToCart({ Code: code }, '/Wishlist/AddToCart', callback);
+ });
+ });
+
+ }
+
+ addToCartClick() {
+ let inst = this;
+
+ $(this.divContainerId).find('.addToCart').each(function (i, e) {
+ $(e).attr("href", "javascript:void(0);")
+ $(e).click(function () {
+ let code = $(this).attr('data');
+ let data = {
+ Code: code
+ };
+
+ if ($(this).attr('qty')) data.Quantity = $(this).attr('qty');
+ if ($(this).attr('store')) data.Store = $(this).attr('store');
+ if ($(this).attr('selectedStore')) data.SelectedStore = $(this).attr('selectedStore');
+
+ let callback = (count) => {
+ inst.callbackAddToCart('.jsCartBtn', count);
+ };
+
+ inst.addToCart(data, '/DefaultCart/AddToCart', callback, true);
+ });
+ });
+ }
+
+ deleteWishlistClick() {
+ let inst = this;
+
+ $(this.divContainerId).find('.deleteLineItemWishlist').each(function (i, e) {
+ $(e).click(function () {
+ if (confirm("Are you sure?")) {
+ let code = $(e).attr('data');
+ let data = { Code: code, Quantity: 0, RequestFrom: "axios" };
+ let callback = (count) => {
+ inst.callbackAddToCart("#js-wishlist", count);
+ };
+ inst.removeItem(data, '/Wishlist/ChangeCartItem', "Removed " + code + " from wishlist", callback);
+ }
+ });
+ });
+ }
+
+ addAllToCartClick() {
+ $(this.divContainerId).find('.jsAddAllToCart').each(function (i, e) {
+ $(e).click(function () {
+ $('.loading-box').show();
+ let url = $(this).attr('url');
+ axios.post(url)
+ .then(function (result) {
+ notification.success(result.data.Message);
+ cartHelper.setCartReload(result.data.CountItems);
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $('.loading-box').hide();
+ });
+
+ });
+ });
+
+ }
}
\ No newline at end of file
diff --git a/src/Foundation/Features/NamedCarts/Cart.js b/src/Foundation/Features/NamedCarts/Cart.js
index d24b81c7a..9a20f11de 100644
--- a/src/Foundation/Features/NamedCarts/Cart.js
+++ b/src/Foundation/Features/NamedCarts/Cart.js
@@ -1,360 +1,360 @@
export class Cart {
- changeInfoCart(result) {
- $('.largecart-Subtotal').html("$" + result.data.SubTotal.Amount);
- $('.largecart-TotalDiscount').html("$" + result.data.TotalDiscount.Amount);
- $('.largecart-TaxTotal').html("$" + result.data.TaxTotal.Amount);
- $('.largecart-ShippingTotal').html("$" + result.data.ShippingTotal.Amount);
- $('.largecart-Total').html("$" + result.data.Total.Amount);
-
- cartHelper.setCartReload(result.data.CountItems);
- }
-
- removeItem(url, elementClick, typeCart) {
- var inst = this;
- var data = {
- Code: elementClick.attr('code'),
- ShipmentId: elementClick.attr('shipmentId'),
- RequestFrom: elementClick.attr('type')
- };
-
- axios.post(url, data)
- .then(function (result) {
- if (result.data.StatusCode == 0) {
- notification.error(result.data.Message);
- }
- else if (result.data.StatusCode == 1) {
- if (typeCart == 'cart') {
- $('.countItemCartHeader').each(function (i, el) {
- $(el).html(result.data.CountItems);
- });
- $('.amountCartHeader').each(function (i, el) {
- $(el).html("$" + result.data.SubTotal.Amount);
- });
- }
-
- if (typeCart !== 'large-cart' && typeCart !== "shared-cart-large") {
- elementClick.parents('.cart__row').first().remove();
- if (typeCart == "cart") cartHelper.setCartReload(result.data.CountItems);
- else if (typeCart == "shared-cart") cartHelper.setSharedCartReload(result.data.CountItems);
- else cartHelper.setWishlistReload(result.data.CountItems);
-
- } else { // if large cart, large shared
- if (typeCart == "shared-cart-large") {
- elementClick.parents('tr').first().remove();
- cartHelper.setSharedCartReload(result.data.CountItems);
- } else {
- elementClick.parents('.product-tile-list__item').first().remove();
- inst.changeInfoCart(result);
- }
- }
- }
- else {
- notification.error(result.data.Message);
- }
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
-
- });
- }
-
- moveToWishlist(element) {
- var inst = this;
- $('.loading-box').show();
- var url = $(element).attr('url');
- var code = $(element).attr('code');
- axios.post(url, { Code: code })
- .then(function (result) {
- if (result.data.StatusCode === 1) {
- inst.changeInfoCart(result);
- element.parents('.product-tile-list__item').first().remove();
-
- cartHelper.AddWishlist();
- notification.success(result.data.Message);
- } else {
- notification.warning(result.data.Message);
- }
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
- $('.loading-box').hide();
+ changeInfoCart(result) {
+ $('.largecart-Subtotal').html("$" + result.data.SubTotal.Amount);
+ $('.largecart-TotalDiscount').html("$" + result.data.TotalDiscount.Amount);
+ $('.largecart-TaxTotal').html("$" + result.data.TaxTotal.Amount);
+ $('.largecart-ShippingTotal').html("$" + result.data.ShippingTotal.Amount);
+ $('.largecart-Total').html("$" + result.data.Total.Amount);
+
+ cartHelper.setCartReload(result.data.CountItems);
+ }
+
+ removeItem(url, elementClick, typeCart) {
+ var inst = this;
+ var data = {
+ Code: elementClick.attr('code'),
+ ShipmentId: elementClick.attr('shipmentId'),
+ RequestFrom: elementClick.attr('type')
+ };
+
+ axios.post(url, data)
+ .then(function (result) {
+ if (result.data.StatusCode == 0) {
+ notification.error(result.data.Message);
+ }
+ else if (result.data.StatusCode == 1) {
+ if (typeCart == 'cart') {
+ $('.countItemCartHeader').each(function (i, el) {
+ $(el).html(result.data.CountItems);
});
- }
-
- changeVariant(url, data, elementChange) {
- var inst = this;
- axios.post(url, data)
- .then(function (result) {
- var container = $(elementChange).parents('.product-tile-list__item').first();
- $(container).html(result.data);
- inst.initCartItems(container);
- feather.replace();
- var dropdown = new Dropdown(container);
- dropdown.Init();
- notification.success("Success");
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
-
+ $('.amountCartHeader').each(function (i, el) {
+ $(el).html("$" + result.data.SubTotal.Amount);
});
+ }
+
+ if (typeCart !== 'large-cart' && typeCart !== "shared-cart-large") {
+ elementClick.parents('.cart__row').first().remove();
+ if (typeCart == "cart") cartHelper.setCartReload(result.data.CountItems);
+ else if (typeCart == "shared-cart") cartHelper.setSharedCartReload(result.data.CountItems);
+ else cartHelper.setWishlistReload(result.data.CountItems);
+
+ } else { // if large cart, large shared
+ if (typeCart == "shared-cart-large") {
+ elementClick.parents('tr').first().remove();
+ cartHelper.setSharedCartReload(result.data.CountItems);
+ } else {
+ elementClick.parents('.product-tile-list__item').first().remove();
+ inst.changeInfoCart(result);
+ }
+ }
+ }
+ else {
+ notification.error(result.data.Message);
+ }
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+
+ });
+ }
+
+ moveToWishlist(element) {
+ var inst = this;
+ $('.loading-box').show();
+ var url = $(element).attr('url');
+ var code = $(element).attr('code');
+ axios.post(url, { Code: code })
+ .then(function (result) {
+ if (result.data.StatusCode === 1) {
+ inst.changeInfoCart(result);
+ element.parents('.product-tile-list__item').first().remove();
+
+ cartHelper.AddWishlist();
+ notification.success(result.data.Message);
+ } else {
+ notification.warning(result.data.Message);
+ }
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $('.loading-box').hide();
+ });
+ }
+
+ changeVariant(url, data, elementChange) {
+ var inst = this;
+ axios.post(url, data)
+ .then(function (result) {
+ var container = $(elementChange).parents('.product-tile-list__item').first();
+ $(container).html(result.data);
+ inst.initCartItems(container);
+ feather.replace();
+ var dropdown = new Dropdown(container);
+ dropdown.init();
+ notification.success("Success");
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+
+ });
+ }
+
+ changeQuantity(element) {
+ var inst = this;
+ var code = $(element).attr('code');
+ var shipmentId = $(element).attr('shipmentId');
+ var qty = $(element).val();
+ var url = $(element).attr('url');
+ var data = {
+ Code: code,
+ ShipmentId: shipmentId,
+ Quantity: qty
+ };
+ $(element).attr('disabled', 'disabled');
+ axios.post(url, data)
+ .then(function (result) {
+ switch (result.data.StatusCode) {
+ case 0:
+ $(element).siblings('.required').html(result.data.Message);
+ notification.warning(result.data.Message);
+ break;
+ case -1:
+ notification.error(result.data.Message);
+ break;
+ default:
+ notification.success(result.data.Message);
+ inst.changeInfoCart(result);
+ var subtotal = parseFloat($(element).attr('unitPrice')) * qty;
+ $('.subtotal-' + code).html($(element).attr('currency') + subtotal);
+ $(element).parents('.product-tile-list__item').first().find('.currentVariantInfo').attr('quantity', qty);
+ break;
+ }
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $(element).removeAttr('disabled');
+ });
+ }
+
+
+ initClearCart() {
+ $('#clearCart').click(function () {
+ if (confirm("Are you sure?")) {
+ $('.loading-box').show();
+ var url = $(this).attr('url');
+ axios.post(url)
+ .then(function (result) {
+ notification.success("Delete cart successfully.");
+ setTimeout(function () { window.location.href = result.data; }, 1000);
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $('.loading-box').hide();
+ });
+ }
+ });
+ }
+
+ loadMiniCartClick(urlLoadCart, clickSelector, reloadSelector) {
+ var inst = this;
+ $(clickSelector).click(function () {
+ var isNeedReload = $(this).attr('reload');
+ if (isNeedReload == 1) { // reload mini cart
+ $(reloadSelector + " .loading-cart").show();
+ axios.get(urlLoadCart, null)
+ .then(function (result) {
+ $(reloadSelector + " .cart-item-listing").html(result.data);
+ inst.initRemoveItem(reloadSelector);
+ $(clickSelector).attr('reload', 0);
+ })
+ .catch(function (error) {
+ notification.error(error);
+ })
+ .finally(function () {
+ $(reloadSelector + " .loading-cart").hide();
+ });
+ }
+ });
+ }
+
+ initLoadCarts() {
+ var inst = this;
+ $('.jsCartBtn').each(function (i, e) {
+ var url = $(e).data("reloadurl");
+ var container = $(e).data("cartcontainer");
+ inst.loadMiniCartClick(url, e, container);
+ });
+ $('.jsWishlistBtn').each(function (i, e) {
+ var url = $(e).data("reloadurl");
+ var container = $(e).data("cartcontainer");
+ inst.loadMiniCartClick(url, e, container);
+ });
+ $('.jsSharedCartBtn').each(function (i, e) {
+ var url = $(e).data("reloadurl");
+ var container = $(e).data("cartcontainer");
+ inst.loadMiniCartClick(url, e, container);
+ });
+ }
+
+ initChangeVariant(selector) {
+ var inst = this;
+ if (selector == undefined) {
+ selector = document;
}
- changeQuantity(element) {
- var inst = this;
- var code = $(element).attr('code');
- var shipmentId = $(element).attr('shipmentId');
- var qty = $(element).val();
- var url = $(element).attr('url');
+ $(selector).find('.jsChangeSizeVariantLargeCart').each(function (i, e) {
+ $(e).change(function () {
+ var parent = $(e).parents('.product-tile-list__item').first();
+ var variantInfo = $(parent).find('.currentVariantInfo').first();
var data = {
- Code: code,
- ShipmentId: shipmentId,
- Quantity: qty
+ Code: variantInfo.val(),
+ Size: variantInfo.attr('size'),
+ Quantity: variantInfo.attr('quantity'),
+ NewSize: $(e).val(),
+ ShipmentId: variantInfo.attr('shipmentId'),
+ RequestFrom: "changeSizeItem"
};
- $(element).attr('disabled', 'disabled');
- axios.post(url, data)
- .then(function (result) {
- switch (result.data.StatusCode) {
- case 0:
- $(element).siblings('.required').html(result.data.Message);
- notification.warning(result.data.Message);
- break;
- case -1:
- notification.error(result.data.Message);
- break;
- default:
- notification.success(result.data.Message);
- inst.changeInfoCart(result);
- var subtotal = parseFloat($(element).attr('unitPrice')) * qty;
- $('.subtotal-' + code).html($(element).attr('currency') + subtotal);
- $(element).parents('.product-tile-list__item').first().find('.currentVariantInfo').attr('quantity', qty);
- break;
- }
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
- $(element).removeAttr('disabled');
- });
- }
-
-
- initClearCart() {
- $('#clearCart').click(function () {
- if (confirm("Are you sure?")) {
- $('.loading-box').show();
- var url = $(this).attr('url');
- axios.post(url)
- .then(function (result) {
- notification.success("Delete cart successfully.");
- setTimeout(function () { window.location.href = result.data; }, 1000);
- })
- .catch(function (error) {
- notification(error);
- })
- .finally(function () {
- $('.loading-box').hide();
- });
- }
- });
- }
+ var url = variantInfo.attr('url');
- loadMiniCartClick(urlLoadCart, clickSelector, reloadSelector) {
- var inst = this;
- $(clickSelector).click(function () {
- var isNeedReload = $(this).attr('reload');
- if (isNeedReload == 1) { // reload mini cart
- $(reloadSelector + " .loading-cart").show();
- axios.get(urlLoadCart, null)
- .then(function (result) {
- $(reloadSelector + " .cart-item-listing").html(result.data);
- inst.initRemoveItem(reloadSelector);
- $(clickSelector).attr('reload', 0);
- })
- .catch(function (error) {
- notification.error(error);
- })
- .finally(function () {
- $(reloadSelector + " .loading-cart").hide();
- });
- }
- });
- }
+ inst.changeVariant(url, data, e);
+ });
+ });
+ }
- initLoadCarts() {
- var inst = this;
- $('.jsCartBtn').each(function (i, e) {
- var url = $(e).data("reloadurl");
- var container = $(e).data("cartcontainer");
- inst.loadMiniCartClick(url, e, container);
- });
- $('.jsWishlistBtn').each(function (i, e) {
- var url = $(e).data("reloadurl");
- var container = $(e).data("cartcontainer");
- inst.loadMiniCartClick(url, e, container);
- });
- $('.jsSharedCartBtn').each(function (i, e) {
- var url = $(e).data("reloadurl");
- var container = $(e).data("cartcontainer");
- inst.loadMiniCartClick(url, e, container);
- });
+ initMoveToWishtlist(selector) {
+ var inst = this;
+ if (selector == undefined) {
+ selector = document;
}
-
- initChangeVariant(selector) {
- var inst = this;
- if (selector == undefined) {
- selector = document;
- }
-
- $(selector).find('.jsChangeSizeVariantLargeCart').each(function (i, e) {
- $(e).change(function () {
- var parent = $(e).parents('.product-tile-list__item').first();
- var variantInfo = $(parent).find('.currentVariantInfo').first();
- var data = {
- Code: variantInfo.val(),
- Size: variantInfo.attr('size'),
- Quantity: variantInfo.attr('quantity'),
- NewSize: $(e).val(),
- ShipmentId: variantInfo.attr('shipmentId'),
- RequestFrom: "changeSizeItem"
- };
- var url = variantInfo.attr('url');
-
- inst.changeVariant(url, data, e);
- });
- });
+ $(selector).find('.jsMoveToWishlist').each(function (i, e) {
+ $(e).click(function () {
+ inst.moveToWishlist($(e));
+ });
+ });
+ }
+
+ initChangeQuantityItem(selector) {
+ var inst = this;
+ if (selector == undefined) {
+ selector = document;
}
-
- initMoveToWishtlist(selector) {
- var inst = this;
- if (selector == undefined) {
- selector = document;
+ $(selector).find('.jsChangeQuantityCartItem').each(function (i, e) {
+ $(e).change(function () {
+ var valueInt = parseInt($(e).val());
+ if (!isNaN(valueInt) && Number.isInteger(valueInt)) {
+ $(e).siblings('.required').html("");
+ if (valueInt > 0)
+ inst.changeQuantity($(e));
+ else {
+ if (confirm("Are you sure delete this item?")) {
+ var elementDelete = $(e).parents('.product-tile-list__item').first().find('.jsRemoveCartItem').first();
+ inst.removeItem('/defaultcart/RemoveCartItem', elementDelete, "large-cart");
+ }
+ }
}
- $(selector).find('.jsMoveToWishlist').each(function (i, e) {
- $(e).click(function () {
- inst.moveToWishlist($(e));
- });
- });
- }
-
- initChangeQuantityItem(selector) {
- var inst = this;
- if (selector == undefined) {
- selector = document;
+ else {
+ $(e).siblings('.required').html("This field must be a number.");
}
- $(selector).find('.jsChangeQuantityCartItem').each(function (i, e) {
- $(e).change(function () {
- var valueInt = parseInt($(e).val());
- if (!isNaN(valueInt) && Number.isInteger(valueInt)) {
- $(e).siblings('.required').html("");
- if (valueInt > 0)
- inst.changeQuantity($(e));
- else {
- if (confirm("Are you sure delete this item?")) {
- var elementDelete = $(e).parents('.product-tile-list__item').first().find('.jsRemoveCartItem').first();
- inst.removeItem('/defaultcart/RemoveCartItem', elementDelete, "large-cart");
- }
- }
- }
- else {
- $(e).siblings('.required').html("This field must be a number.");
- }
- });
- });
- }
-
+ });
+ });
+ }
- initRemoveItem(selector) {
- var inst = this;
- if (selector == undefined) {
- selector = document;
- }
- $(selector).find('.jsRemoveCartItem').each(function (i, e) {
- $(e).click(function () {
- if (confirm("Are you sure?")) {
- var type = $(this).attr('type');
- var url = "/defaultcart/RemoveCartItem";
- //var typeCart = "#js-cart";
- if (type === "wishlist") {
- url = "/wishlist/RemoveWishlistItem";
- //typeCart = "#js-wishlist";
- }
-
- if (type === "large-cart") {
- url = "/defaultcart/RemoveCartItem";
- //typeCart = "#cartItemsId";
- }
-
- if (type === "shared-cart") {
- url = "/sharedcart/RemoveCartItem";
- //typeCart = "#jsSharedCartContainer";
- }
-
- if (type === "shared-cart-large") {
- url = "/sharedcart/RemoveCartItem";
- }
-
- inst.removeItem(url, $(this), type);
- }
- });
- });
+ initRemoveItem(selector) {
+ var inst = this;
+ if (selector == undefined) {
+ selector = document;
}
- initCartItems(selector) {
- var inst = this;
- inst.initRemoveItem(selector);
- inst.initChangeQuantityItem(selector);
- inst.initMoveToWishtlist(selector);
- inst.initChangeVariant(selector);
- }
+ $(selector).find('.jsRemoveCartItem').each(function (i, e) {
+ $(e).click(function () {
+ if (confirm("Are you sure?")) {
+ var type = $(this).attr('type');
+ var url = "/defaultcart/RemoveCartItem";
+ //var typeCart = "#js-cart";
+ if (type === "wishlist") {
+ url = "/wishlist/RemoveWishlistItem";
+ //typeCart = "#js-wishlist";
+ }
+
+ if (type === "large-cart") {
+ url = "/defaultcart/RemoveCartItem";
+ //typeCart = "#cartItemsId";
+ }
+
+ if (type === "shared-cart") {
+ url = "/sharedcart/RemoveCartItem";
+ //typeCart = "#jsSharedCartContainer";
+ }
+
+ if (type === "shared-cart-large") {
+ url = "/sharedcart/RemoveCartItem";
+ }
+
+ inst.removeItem(url, $(this), type);
+ }
+ });
+ });
+ }
+
+ initCartItems(selector) {
+ var inst = this;
+ inst.initRemoveItem(selector);
+ inst.initChangeQuantityItem(selector);
+ inst.initMoveToWishtlist(selector);
+ inst.initChangeVariant(selector);
+ }
}
export class CartHelper {
- setCartReload(totalItem) {
- if (totalItem != undefined) {
- $('.jsCartBtn').each(function (i, e) {
- $(e).find('.icon-menu__badge').first().html(totalItem);
- $(e).attr('reload', 1);
- });
- }
+ setCartReload(totalItem) {
+ if (totalItem != undefined) {
+ $('.jsCartBtn').each(function (i, e) {
+ $(e).find('.icon-menu__badge').first().html(totalItem);
+ $(e).attr('reload', 1);
+ });
}
-
- setWishlistReload(totalItem) {
- if (totalItem != undefined) {
- $('.jsWishlistBtn').each(function (i, e) {
- $(e).find('.icon-menu__badge').first().html(totalItem);
- $(e).attr('reload', 1);
- });
- }
+ }
+
+ setWishlistReload(totalItem) {
+ if (totalItem != undefined) {
+ $('.jsWishlistBtn').each(function (i, e) {
+ $(e).find('.icon-menu__badge').first().html(totalItem);
+ $(e).attr('reload', 1);
+ });
}
-
- setSharedCartReload(totalItem) {
- if (totalItem != undefined) {
- $('.jsSharedCartBtn').each(function (i, e) {
- $(e).find('.icon-menu__badge').first().html(totalItem);
- $(e).attr('reload', 1);
- });
- }
+ }
+
+ setSharedCartReload(totalItem) {
+ if (totalItem != undefined) {
+ $('.jsSharedCartBtn').each(function (i, e) {
+ $(e).find('.icon-menu__badge').first().html(totalItem);
+ $(e).attr('reload', 1);
+ });
}
+ }
- addWishlist() {
- var wishlistHeader = $('#js-wishlist').children('.icon-menu__badge').first();
+ addWishlist() {
+ var wishlistHeader = $('#js-wishlist').children('.icon-menu__badge').first();
- var newQty = parseInt(wishlistHeader.html()) + 1;
- this.SetWishlistReload(newQty);
- }
+ var newQty = parseInt(wishlistHeader.html()) + 1;
+ this.SetWishlistReload(newQty);
+ }
- subtractWishlist() {
- var wishlistHeader = $('#js-wishlist').children('.icon-menu__badge').first();
+ subtractWishlist() {
+ var wishlistHeader = $('#js-wishlist').children('.icon-menu__badge').first();
- var newQty = parseInt(wishlistHeader.html()) + 1;
- this.SetWishlistReload(newQty);
- }
+ var newQty = parseInt(wishlistHeader.html()) + 1;
+ this.SetWishlistReload(newQty);
+ }
}
\ No newline at end of file
diff --git a/src/Foundation/Features/Shared/Views/Header/_MiniCartItems.cshtml b/src/Foundation/Features/Shared/Views/Header/_MiniCartItems.cshtml
index 14fb76763..17891012d 100644
--- a/src/Foundation/Features/Shared/Views/Header/_MiniCartItems.cshtml
+++ b/src/Foundation/Features/Shared/Views/Header/_MiniCartItems.cshtml
@@ -46,10 +46,10 @@
Subtotal ( items):
-
diff --git a/src/Foundation/Features/Shared/Views/Header/_MiniSharedCartItems.cshtml b/src/Foundation/Features/Shared/Views/Header/_MiniSharedCartItems.cshtml
index a255924de..0700fc129 100644
--- a/src/Foundation/Features/Shared/Views/Header/_MiniSharedCartItems.cshtml
+++ b/src/Foundation/Features/Shared/Views/Header/_MiniSharedCartItems.cshtml
@@ -41,7 +41,7 @@
Subtotal ( items):
-
+
View details
diff --git a/src/Foundation/Features/Shared/Views/Header/_MiniWishlistItems.cshtml b/src/Foundation/Features/Shared/Views/Header/_MiniWishlistItems.cshtml
index 7e8efdc60..a4b974942 100644
--- a/src/Foundation/Features/Shared/Views/Header/_MiniWishlistItems.cshtml
+++ b/src/Foundation/Features/Shared/Views/Header/_MiniWishlistItems.cshtml
@@ -31,7 +31,7 @@
}
\ No newline at end of file