@Loc["Products.Compare.Title"]
- @if (Model.Products.Any())
- {
-
+
+ @Loc["Products.Compare.Clear"]
-
+
| |
- @foreach (var product in Model.Products)
- {
-
- |
| |
- @foreach (var product in Model.Products)
- {
-
-
+
+
+
|
- }
+
|
|
|
- @foreach (var product in Model.Products)
- {
-
- @product.Name
+
+ |
+ {{product.Name}}
|
- }
+
|
|
|
- @foreach (var product in Model.Products)
- {
-
- @product.ProductPrice.Price
+
+ |
+ {{product.ProductPrice.Price}}
|
- }
+
|
- @if (Model.IncludeShortDescriptionInCompareProducts)
- {
+
|
|
- @foreach (var product in Model.Products)
- {
-
- @Html.Raw(product.ShortDescription)
+
+ |
+
|
- }
+
|
- }
- @foreach (var specificationAttribute in specificationAttributes)
- {
+
+
|
-
+
|
- @foreach (var product in Model.Products)
- {
- var foundProductSpec = product.SpecificationAttributeModels.FirstOrDefault(psa => psa.SpecificationAttributeId == specificationAttribute.SpecificationAttributeId);
- var specValue = foundProductSpec != null ? foundProductSpec.ValueRaw : "";
-
-
- @if (foundProductSpec != null)
- {
- if (String.IsNullOrEmpty(foundProductSpec.ColorSquaresRgb))
- {
- @Html.Raw(foundProductSpec.ValueRaw)
- }
- else
- {
-
-
-
-
-
- }
- }
- else
- {
-
- }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
- }
+
|
- }
- @if (Model.IncludeFullDescriptionInCompareProducts)
- {
+
+
|
|
- @foreach (var product in Model.Products)
- {
-
- @Html.Raw(product.FullDescription)
+
+ |
+
|
- }
+
|
- }
+
- }
- else
- {
+
+
@Loc["Products.Compare.NoItems"]
- }
+
+
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/_AddToWishlist.cshtml b/src/Web/Grand.Web/Views/Product/_AddToWishlist.cshtml
index ffaab09b7..2f8518e0a 100644
--- a/src/Web/Grand.Web/Views/Product/_AddToWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Product/_AddToWishlist.cshtml
@@ -11,8 +11,8 @@
addToWishlistText = Loc["ShoppingCart.AddToWishlist"];
}
-
+
@addToWishlistText
-
+
}
diff --git a/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml b/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
index 462943f15..f1fba9474 100644
--- a/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
+++ b/src/Web/Grand.Web/Views/Product/_ProductsComparison.cshtml
@@ -4,7 +4,7 @@
}
@if (Model.CompareProductsEnabled)
{
-
+
@Loc["Products.Compare.AddToCompareList"]
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
index 7ade3726f..842c36880 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
@@ -41,10 +41,6 @@
{
@Loc["Products.RecentlyViewedProducts"]
}
- @if (Model.CompareProductsEnabled)
- {
- @Loc["Products.Compare.List"]
- }
@if (Model.NewProductsEnabled)
{
@Loc["Products.NewProducts"]
diff --git a/src/Web/Grand.Web/Views/Shared/Header.cshtml b/src/Web/Grand.Web/Views/Shared/Header.cshtml
index 17cb0d930..2bffcd0a8 100644
--- a/src/Web/Grand.Web/Views/Shared/Header.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Header.cshtml
@@ -4,7 +4,7 @@
}
diff --git a/src/Web/Grand.Web/Views/Shared/SidebarWishlist.cshtml b/src/Web/Grand.Web/Views/Shared/SidebarWishlist.cshtml
index 4a7417e43..eafe3286a 100644
--- a/src/Web/Grand.Web/Views/Shared/SidebarWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/SidebarWishlist.cshtml
@@ -41,20 +41,24 @@
-
-
-
-
- @Loc["Wishlist"]
-
-
-
-
- @Loc["Wishlist.EmailAFriend"]
+
diff --git a/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml b/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
index e7c1059f2..6644b0c4a 100644
--- a/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CatalogProductView.cshtml
@@ -290,7 +290,7 @@
}
@if (!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == ProductType.SimpleProduct)
{
-
+
AddToCompareList
diff --git a/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml b/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
index 00074cd7b..274d01c8a 100644
--- a/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CatalogProductViewVue.cshtml
@@ -227,7 +227,7 @@
-
+
AddToCompareList
diff --git a/src/Web/Grand.Web/Views/Shared/_Layout.cshtml b/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
index 6f480d135..88766b4ef 100644
--- a/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
@@ -37,7 +37,7 @@
-
+
@await Component.InvokeAsync("Widget", new { widgetZone = "content_before" })
@if (IsSectionDefined("Breadcrumb"))
{
diff --git a/src/Web/Grand.Web/Views/Shared/_ShoppingCartLinks.cshtml b/src/Web/Grand.Web/Views/Shared/_ShoppingCartLinks.cshtml
index baf9b6fde..c5ed42f80 100644
--- a/src/Web/Grand.Web/Views/Shared/_ShoppingCartLinks.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_ShoppingCartLinks.cshtml
@@ -1,6 +1,7 @@
@inject IWorkContext workContext
@inject Grand.Business.Common.Interfaces.Security.IPermissionService permissionService
@inject ShoppingCartSettings shoppingCartSettings
+@inject CatalogSettings catalogSettings
@using Grand.Business.Common.Services.Security
@using Grand.Business.Checkout.Extensions
@{
@@ -26,7 +27,10 @@
.Sum(x => x.Quantity) : 0;
}
-
+@if (catalogSettings.CompareProductsEnabled)
+{
+
+}
@if (wishlistEnabled || shoppingCartEnabled)
{
@if (miniShoppingCartEnabled)
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/common/common.css b/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
index 138f71234..ba1319698 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
@@ -1017,14 +1017,13 @@ input:checked ~ .color-container .color::before {
}
.product-box .quick-view-button {
position: absolute;
- bottom: 1px;
+ bottom: 0;
left: 1px;
width: calc(100% - 2px);
font-size: 16px;
font-weight: 500;
text-transform: uppercase;
border: 0;
- border-top: 1px solid;
border-radius: 0;
transform: translateY(100%);
-webkit-transform: translateY(100%);
@@ -1262,11 +1261,8 @@ input:checked ~ .color-container .color::before {
border-bottom-right-radius: 0;
}
-/* container wide */
+/* main container */
-.main-container.container-fluid .product-box.list .card-body {
- flex: 4;
-}
.main-container {
min-height: 350px;
}
@@ -1288,6 +1284,15 @@ input:checked ~ .color-container .color::before {
border-radius: 100%;
}
+/* comapre products table */
+
+.compare-products-table td.same-width {
+ width: 25%
+}
+.compare-products-table .compare-img {
+ max-width: 250px;
+}
+
/* autocomplete */
.vbt-autcomplete-list[data-v-48792d67] {
@@ -1392,36 +1397,7 @@ footer .list-group-item span:last-child {
/* media */
-@media (min-width: 992px) {
- .main-container.container-fluid .product-grid .product-container.col-lg-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
-}
-@media (min-width: 1200px) {
- .main-container.container-fluid .categoryGrid .col-md-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
- .main-container.container-fluid .product-grid .product-container.col-xl-3 {
- -ms-flex: 0 0 16.666667%;
- flex: 0 0 16.666667%;
- max-width: 16.666667%;
- }
- .main-container.container-fluid .featured-product-container.col-xl-6 {
- -ms-flex: 0 0 33.333333%;
- flex: 0 0 33.333333%;
- max-width: 33.333333%;
- }
-}
@media (min-width: 1400px) {
- .main-container.container-fluid .categoryGrid .col-xl-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
.container, .container-lg, .container-md, .container-sm, .container-xl {
max-width: 1350px;
}
@@ -1430,6 +1406,9 @@ footer .list-group-item span:last-child {
.container, .container-lg, .container-md, .container-sm {
max-width: 100%;
}
+ .compare-products-table td.same-width {
+ width: 33.333333%;
+ }
}
@media (max-width: 991px) {
footer .list-group-item:not(.list-group-item-action) {
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css b/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
index d9683a62b..c8d55214d 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
@@ -1156,14 +1156,13 @@ input:checked ~ .color-container .color::before {
}
.product-box .quick-view-button {
position: absolute;
- bottom: 1px;
+ bottom: 0;
left: 1px;
width: calc(100% - 2px);
font-size: 16px;
font-weight: 500;
text-transform: uppercase;
border: 0;
- border-top: 1px solid;
border-radius: 0;
transform: translateY(100%);
-webkit-transform: translateY(100%);
@@ -1406,11 +1405,8 @@ input:checked ~ .color-container .color::before {
border-bottom-right-radius: 0;
}
-/* container wide */
+/* main container */
-.main-container.container-fluid .product-box.list .card-body {
- flex: 4;
-}
.main-container {
min-height: 350px;
}
@@ -1432,6 +1428,15 @@ input:checked ~ .color-container .color::before {
border-radius: 100%;
}
+/* comapre products table */
+
+.compare-products-table td.same-width {
+ width: 25%
+}
+.compare-products-table .compare-img {
+ max-width: 250px;
+}
+
/* autocomplete */
.vbt-autcomplete-list[data-v-48792d67] {
@@ -1540,36 +1545,7 @@ footer .list-group-item span:last-child {
/* media */
-@media (min-width: 992px) {
- .main-container.container-fluid .product-grid .product-container.col-lg-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
-}
-@media (min-width: 1200px) {
- .main-container.container-fluid .categoryGrid .col-md-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
- .main-container.container-fluid .product-grid .product-container.col-xl-3 {
- -ms-flex: 0 0 16.666667%;
- flex: 0 0 16.666667%;
- max-width: 16.666667%;
- }
- .main-container.container-fluid .featured-product-container.col-xl-6 {
- -ms-flex: 0 0 33.333333%;
- flex: 0 0 33.333333%;
- max-width: 33.333333%;
- }
-}
@media (min-width: 1400px) {
- .main-container.container-fluid .categoryGrid .col-xl-4 {
- -ms-flex: 0 0 25%;
- flex: 0 0 25%;
- max-width: 25%;
- }
.container, .container-lg, .container-md, .container-sm, .container-xl {
max-width: 1350px;
}
@@ -1578,6 +1554,9 @@ footer .list-group-item span:last-child {
.container, .container-lg, .container-md, .container-sm {
max-width: 100%;
}
+ .compare-products-table td.same-width {
+ width: 33.333333%;
+ }
}
@media (max-width: 991px) {
footer .list-group-item:not(.list-group-item-action) {
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/header/header.css b/src/Web/Grand.Web/wwwroot/theme/css/header/header.css
index f45b25081..a6f35fd05 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/header/header.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/header/header.css
@@ -48,37 +48,39 @@
/* sidebar-cart */
-.sidebar-cart {
+.sidebar {
padding-left: 0;
}
-
-.sidebar-cart .item {
+.b-sidebar .item {
position: relative;
width: 100%;
margin: 0 0 7.5px 0;
padding: 0 0 7.5px 0;
border-bottom: 1px solid #efefef;
}
-.sidebar-cart .item img {
+.b-sidebar .item img {
background-color: #F8F9FB;
}
-.sidebar-cart .item:last-child,
-.sidebar-cart .item:last-child:first-child {
+.b-sidebar .item.comapre-product img {
+ max-width: 100px;
+}
+.b-sidebar .item:last-child,
+.b-sidebar .item:last-child:first-child {
margin: 0;
padding: 0;
border-bottom: 0;
}
-.sidebar-cart .item .attributes {
+.b-sidebar .item .attributes {
font-size: 14px;
color: #888;
}
-.sidebar-cart .item .deletecartitem {
+.b-sidebar .item .deleteitem {
position: absolute;
top: 0;
right: 0;
cursor: pointer;
}
-.sidebar-cart .item .col a {
+.b-sidebar .item .col a {
color: #343a40;
font-size: 16px;
font-weight: 500;
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index b50c7d51a..f2ee91d8f 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -3,7 +3,6 @@
data: function() {
return {
show: false,
- fluid: false,
hover: false,
darkMode: false,
active: false,
@@ -15,6 +14,8 @@
PopupProductReviewVueModal: null,
index: null,
RelatedProducts: null,
+ compareproducts: null,
+ compareProductsQty: 0,
}
},
props: {
@@ -31,6 +32,7 @@
if (localStorage.fluid == "fluid") this.fluid = "fluid";
if (localStorage.fluid == "") this.fluid = "false";
if (localStorage.darkMode == "true") this.darkMode = true;
+ this.updateCompareProductsQty();
},
watch: {
fluid: function (newName) {
@@ -44,6 +46,15 @@
}
},
methods: {
+ updateCompareProductsQty: function () {
+ const cookie = AxiosCart.getCookie('Grand.CompareProduct');
+ if (cookie !== '') {
+ const qty = cookie.split('|').filter(Boolean).length;
+ this.compareProductsQty = qty;
+ } else {
+ this.compareProductsQty = 0;
+ }
+ },
updateFly: function () {
axios({
baseURL: '/Component/Index?Name=SidebarShoppingCart',
@@ -77,6 +88,35 @@
this.wishindicator = response.data.Items.length
))
},
+ getCompareList: function () {
+ axios({
+ baseURL: '/compareproducts',
+ method: 'get',
+ params: {
+ t: new Date().getTime()
+ },
+ data: null,
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-Response-View': 'Json'
+ }
+ }).then(response => {
+ this.compareproducts = response.data
+ })
+ },
+ removeFromCompareList: function (id) {
+ if (id !== undefined) {
+ const compareList = AxiosCart.getCookie('Grand.CompareProduct');
+ const newCompareList = compareList.replace(id, '');
+
+ AxiosCart.setCookie('Grand.CompareProduct', newCompareList);
+ } else {
+ AxiosCart.setCookie('Grand.CompareProduct', '');
+ }
+ this.updateCompareProductsQty();
+ this.getCompareList();
+ },
showModalOutOfStock: function () {
this.$refs['out-of-stock'].show()
},
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
index 559982e52..d30e74704 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
@@ -136,22 +136,28 @@ var AxiosCart = {
});
},
//add a product to compare list
- addproducttocomparelist: function (urladd) {
+ addproducttocomparelist: function (id, message) {
if (this.loadWaiting != false) {
return;
}
this.setLoadWaiting(true);
- axios({
- url: urladd,
- method: 'post'
- }).then(function (response) {
- this.AxiosCart.success_process(response);
- }).catch(function (error) {
- error.axiosFailure;
- }).then(function () {
- this.AxiosCart.resetLoadWaiting();
- });
+ var cookie = this.getCookie('Grand.CompareProduct');
+ if (cookie !== '') {
+ if (!cookie.includes(id)) {
+ cookie = cookie + '|' + id;
+ }
+ } else {
+ cookie = id;
+ }
+ this.setCookie('Grand.CompareProduct', cookie);
+ vm.updateCompareProductsQty();
+
+ displayBarNotification(message, 'success', 3500);
+
+ this.resetLoadWaiting();
+
+ return false;
},
setLoadWaiting: function (display) {
@@ -173,15 +179,15 @@ var AxiosCart = {
vm.flycartindicator = newfly.TotalProducts;
}
- if (response.data.comparemessage) {
- if (response.data.success == true) {
- displayBarNotification(response.data.comparemessage, 'success', 3500);
- }
- else {
- displayBarNotification(response.data.comparemessage, 'error', 3500);
- }
- return false;
- }
+ //if (response.data.comparemessage) {
+ // if (response.data.success == true) {
+ // displayBarNotification(response.data.comparemessage, 'success', 3500);
+ // }
+ // else {
+ // displayBarNotification(response.data.comparemessage, 'error', 3500);
+ // }
+ // return false;
+ //}
if (response.data.product) {
if (response.data.success == true) {
@@ -239,5 +245,28 @@ var AxiosCart = {
axiosFailure: function () {
alert('Failed to add the product. Please refresh the page and try one more time.');
+ },
+ setCookie: function (cname, cvalue, exdays) {
+ const d = new Date();
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
+ let expires = "expires=" + d.toUTCString();
+ document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
+ },
+ getCookie: function (cname) {
+ let name = cname + "=";
+ let ca = document.cookie.split(';');
+ for (let i = 0; i < ca.length; i++) {
+ let c = ca[i];
+ while (c.charAt(0) == ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) == 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return "";
+ },
+ deleteCookie: function (cname) {
+ document.cookie = "" + cname +"=; expires=Thu, 01 Jan 1970 00:00:00 UTC;"
}
-};
\ No newline at end of file
+};