product compare updates

This commit is contained in:
shubhammehrotra.symfony@webkul.com 2020-02-28 17:23:01 +05:30
parent 772cdbd2ba
commit c5c1c9154a
16 changed files with 246 additions and 192 deletions

View File

@ -42,10 +42,10 @@ class AttributeTableSeeder extends Seeder
['id' => '9','code' => 'short_description','admin_name' => 'Short Description','type' => 'textarea','validation' => NULL,'position' => '9','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0',
'is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'],
['id' => '10','code' => 'description','admin_name' => 'Description','type' => 'textarea','validation' => NULL,'position' => '10','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0',
['id' => '11','code' => 'price','admin_name' => 'Price','type' => 'price','validation' => 'decimal','position' => '11','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0',
'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '1'],
['id' => '11','code' => 'price','admin_name' => 'Price','type' => 'price','validation' => 'decimal','position' => '11','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0',
['id' => '10','code' => 'description','admin_name' => 'Description','type' => 'textarea','validation' => NULL,'position' => '10','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0',
'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '1'],
['id' => '12','code' => 'cost','admin_name' => 'Cost','type' => 'price','validation' => 'decimal','position' => '12','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0',

View File

@ -31,9 +31,4 @@ class Attribute extends TranslatableModel implements AttributeContract
{
return $query->where('is_filterable', 1)->where('swatch_type', '<>', 'image')->orderBy('position');
}
public function getComparableAttributes()
{
return $this->where('is_comparable', 1)->orderBy('position')->get();
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
{
"/js/velocity.js": "/js/velocity.js?id=30291e918765474367ba",
"/js/velocity.js": "/js/velocity.js?id=0acc6147ad60ac08da04",
"/css/velocity-admin.css": "/css/velocity-admin.css?id=612d35e452446366eef7",
"/css/velocity.css": "/css/velocity.css?id=8d931d4320879b268a6d"
"/css/velocity.css": "/css/velocity.css?id=ceec6d6cde43e397bf26"
}

View File

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateVelocityCustomerData extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('velocity_customer_data', function (Blueprint $table) {
$table->increments('id');
$table->json('compared_product')->nullable();
$table->unsignedInteger('customer_id');
$table->foreign('customer_id')
->references('id')
->on('customers')
->onDelete('restrict');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('velocity_customer_data');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCustomerCompareProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('velocity_customer_compare_products', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('product_flat_id');
$table->foreign('product_flat_id')
->references('id')
->on('product_flat')
->onUpdate('cascade')
->onDelete('cascade');
$table->unsignedInteger('customer_id');
$table->foreign('customer_id')
->references('id')
->on('customers')
->onUpdate('cascade')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('customer_compare_products');
}
}

View File

@ -5,11 +5,13 @@ namespace Webkul\Velocity\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Cart;
use Webkul\Product\Helpers\ProductImage;
use Webkul\Velocity\Http\Shop\Controllers;
use Webkul\Checkout\Contracts\Cart as CartModel;
use Webkul\Product\Repositories\SearchRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Velocity\Repositories\VelocityCustomerDataRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductsRepository;
use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRepository;
/**
@ -27,6 +29,13 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
*/
protected $_config;
/**
* Webkul\Product\Helpers\ProductImage object
*
* @var ProductImage
*/
protected $productImageHelper;
/**
* SearchRepository object
*
@ -49,31 +58,46 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
protected $velocityProductRepository;
/**
* VelocityCustomerDataRepository object of velocity package
* CategoryRepository object of velocity package
*
* @var VelocityCustomerDataRepository
* @var CategoryRepository
*/
protected $velocityCustomerDataRepository;
protected $categoryRepository;
/**
* VelocityCustomerCompareProductsRepository object of velocity package
*
* @var VelocityCustomerCompareProductsRepository
*/
protected $velocityCompareProductsRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Product\Helpers\ProductImage $productImageHelper
* @param \Webkul\Product\Repositories\SearchRepository $searchRepository
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
* @param \Webkul\Velocity\Repositories\Product\ProductRepository $velocityProductRepository
* @param \Webkul\Velocity\Repositories\VelocityCustomerCompareProductsRepository $velocityCompareProductsRepository
* @return void
*/
public function __construct(
ProductImage $productImageHelper,
SearchRepository $searchRepository,
ProductRepository $productRepository,
CategoryRepository $categoryRepository,
VelocityProductRepository $velocityProductRepository,
VelocityCustomerDataRepository $velocityCustomerDataRepository
VelocityCustomerCompareProductsRepository $velocityCompareProductsRepository
) {
$this->_config = request('_config');
$this->searchRepository = $searchRepository;
$this->productRepository = $productRepository;
$this->productImageHelper = $productImageHelper;
$this->categoryRepository = $categoryRepository;
$this->velocityProductRepository = $velocityProductRepository;
$this->velocityCustomerDataRepository = $velocityCustomerDataRepository;
$this->velocityCompareProductsRepository = $velocityCompareProductsRepository;
}
/**
@ -94,24 +118,23 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
if ($product) {
$productReviewHelper = app('Webkul\Product\Helpers\Review');
$productImageHelper = app('Webkul\Product\Helpers\ProductImage');
$galleryImages = $productImageHelper->getProductBaseImage($product);
$galleryImages = $this->productImageHelper->getProductBaseImage($product);
$response = [
'status' => true,
'status' => true,
'details' => [
'name' => $product->name,
'urlKey' => $product->url_key,
'priceHTML' => $product->getTypeInstance()->getPriceHtml(),
'totalReviews' => $productReviewHelper->getTotalReviews($product),
'rating' => ceil($productReviewHelper->getAverageRating($product)),
'image' => $galleryImages['small_image_url'],
'name' => $product->name,
'urlKey' => $product->url_key,
'image' => $galleryImages['small_image_url'],
'priceHTML' => $product->getTypeInstance()->getPriceHtml(),
'totalReviews' => $productReviewHelper->getTotalReviews($product),
'rating' => ceil($productReviewHelper->getAverageRating($product)),
]
];
} else {
$response = [
'status' => false,
'slug' => $slug,
'slug' => $slug,
];
}
@ -147,7 +170,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
break;
default:
$categoryDetails = app('Webkul\Category\Repositories\CategoryRepository')->findByPath($slug);
$categoryDetails = $this->categoryRepository->findByPath($slug);
if ($categoryDetails) {
$list = false;
@ -162,10 +185,10 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
}
$response = [
'status' => true,
'list' => $list,
'categoryDetails' => $categoryDetails,
'categoryProducts' => $customizedProducts,
'status' => true,
'list' => $list,
'categoryDetails' => $categoryDetails,
'categoryProducts' => $customizedProducts,
];
}
@ -180,25 +203,25 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
public function fetchCategories()
{
$formattedCategories = [];
$categories = app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id);
$categories = $this->categoryRepository->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id);
foreach ($categories as $category) {
array_push($formattedCategories, $this->getCategoryFilteredData($category));
}
return [
'status' => true,
'categories' => $formattedCategories,
'status' => true,
'categories' => $formattedCategories,
];
}
public function fetchFancyCategoryDetails($slug)
{
$categoryDetails = app('Webkul\Category\Repositories\CategoryRepository')->findByPath($slug);
$categoryDetails = $this->categoryRepository->findByPath($slug);
if ($categoryDetails) {
$response = [
'status' => true,
'status' => true,
'categoryDetails' => $this->getCategoryFilteredData($categoryDetails)
];
}
@ -211,46 +234,46 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
private function getCategoryFilteredData($category)
{
$formattedChildCategory = [];
foreach ($category->children as $child) {
array_push($formattedChildCategory, $this->getCategoryFilteredData($child));
}
return [
'id' => $category->id,
'slug' => $category->slug,
'name' => $category->name,
'children' => $formattedChildCategory,
'category_icon_path' => $category->category_icon_path,
'id' => $category->id,
'slug' => $category->slug,
'name' => $category->name,
'children' => $formattedChildCategory,
'category_icon_path' => $category->category_icon_path,
];
}
private function formatProduct($product, $list = false)
{
$reviewHelper = app('Webkul\Product\Helpers\Review');
$productImageHelper = app('Webkul\Product\Helpers\ProductImage');
$totalReviews = $reviewHelper->getTotalReviews($product);
$avgRatings = ceil($reviewHelper->getAverageRating($product));
$galleryImages = $productImageHelper->getGalleryImages($product);
$productImage = $productImageHelper->getProductBaseImage($product)['medium_image_url'];
$galleryImages = $this->productImageHelper->getGalleryImages($product);
$productImage = $this->productImageHelper->getProductBaseImage($product)['medium_image_url'];
return [
'name' => $product->name,
'slug' => $product->url_key,
'image' => $productImage,
'description' => $product->description,
'shortDescription' => $product->short_description,
'galleryImages' => $galleryImages,
'priceHTML' => view('shop::products.price', ['product' => $product])->render(),
'totalReviews' => $totalReviews,
'avgRating' => $avgRatings,
'firstReviewText' => trans('velocity::app.products.be-first-review'),
'addToCartHtml' => view('shop::products.add-to-cart', [
'product' => $product,
'showCompare' => true,
'addWishlistClass' => !(isset($list) && $list) ? '' : '',
'avgRating' => $avgRatings,
'totalReviews' => $totalReviews,
'image' => $productImage,
'galleryImages' => $galleryImages,
'name' => $product->name,
'slug' => $product->url_key,
'description' => $product->description,
'shortDescription' => $product->short_description,
'firstReviewText' => trans('velocity::app.products.be-first-review'),
'priceHTML' => view('shop::products.price', ['product' => $product])->render(),
'addToCartHtml' => view('shop::products.add-to-cart', [
'product' => $product,
'showCompare' => true,
'addWishlistClass' => !(isset($list) && $list) ? '' : '',
'addToCartBtnClass' => !(isset($list) && $list) ? 'small-padding' : '',
])->render(),
];
@ -295,31 +318,33 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
}
$response = [
'status' => 'success',
'totalCartItems' => sizeof($items),
'addedItems' => array_slice($formattedItems, sizeof($formattedBeforeItems)),
'message' => trans('shop::app.checkout.cart.item.success'),
'status' => 'success',
'totalCartItems' => sizeof($items),
'message' => trans('shop::app.checkout.cart.item.success'),
'addedItems' => array_slice($formattedItems, sizeof($formattedBeforeItems)),
];
if ($customer = auth()->guard('customer')->user())
if ($customer = auth()->guard('customer')->user()) {
$this->wishlistRepository->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]);
}
if (request()->get('is_buy_now'))
if (request()->get('is_buy_now')) {
return redirect()->route('shop.checkout.onepage.index');
}
}
} catch(\Exception $exception) {
$product = $this->productRepository->find($id);
$response = [
'status' => 'false',
'message' => trans($exception->getMessage()),
'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key),
'status' => 'false',
'message' => trans($exception->getMessage()),
'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key),
];
}
return $response ?? [
'status' => 'error',
'message' => trans('velocity::app.error.something-went-wrong'),
'status' => 'error',
'message' => trans('velocity::app.error.something-went-wrong'),
];
}
@ -331,35 +356,44 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
public function getComparisonList(Request $request)
{
if (request()->get('data')) {
$customer = null;
$productSlugs = null;
$productCollection = [];
if (auth()->guard('customer')->user()) {
$customer = $this->velocityCustomerDataRepository->findOneByField([
'customer_id' => auth()->guard('customer')->user()->id,
]);
}
$productCollection = $this->velocityCompareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
'product_flat.id'
)
->where('customer_id', auth()->guard('customer')->user()->id)
->get()
->toArray();
if ($customer) {
$productSlugs = json_decode($customer->compared_product, true);
foreach ($productCollection as $index => $customerCompare) {
$product = $this->productRepository->find($customerCompare['product_id']);
$formattedProduct = $this->formatProduct($product);
$productCollection[$index]['image'] = $formattedProduct['image'];
$productCollection[$index]['priceHTML'] = $formattedProduct['priceHTML'];
$productCollection[$index]['addToCartHtml'] = $formattedProduct['addToCartHtml'];
}
} else {
// for product details
if ($items = request()->get('items')) {
$productSlugs = explode('&', $items);
}
}
if ($productSlugs) {
foreach ($productSlugs as $slug) {
$product = $this->productRepository->findBySlug($slug);
foreach ($productSlugs as $slug) {
$product = $this->productRepository->findBySlug($slug);
array_push($productCollection, $this->formatProduct($product));
array_push($productCollection, $this->formatProduct($product));
}
}
}
$response = [
'status' => 'success',
'products' => $productCollection,
'status' => 'success',
'products' => $productCollection,
];
} else {
$response = view($this->_config['view']);
@ -375,38 +409,33 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
*/
public function addCompareProduct()
{
$slug = request()->get('slug');
$productId = request()->get('productId');
$customerId = auth()->guard('customer')->user()->id;
$customer = $this->velocityCustomerDataRepository->findOneByField([
'customer_id' => auth()->guard('customer')->user()->id,
$compareProduct = $this->velocityCompareProductsRepository->findOneByField([
'customer_id' => $customerId,
'product_flat_id' => $productId,
]);
if ($customer) {
// update
$responseCode = 200;
$oldProducts = json_decode($customer->compared_product, true);
$combinedProducts = array_merge($oldProducts, [$slug]);
$uniqueCombinedProducts = array_unique($combinedProducts);
$this->velocityCustomerDataRepository->update([
'compared_product' => json_encode($uniqueCombinedProducts),
], $customer->id);
} else {
if (! $compareProduct) {
// insert new row
$this->velocityCustomerDataRepository->create([
'compared_product' => json_encode([$slug]),
'customer_id' => auth()->guard('customer')->user()->id,
$this->velocityCompareProductsRepository->create([
'customer_id' => $customerId,
'product_flat_id' => $productId,
]);
$responseCode = 201;
return response()->json([
'status' => 'success',
'message' => trans('velocity::app.customer.compare.added'),
'label' => trans('velocity::app.shop.general.alert.success'),
], 201);
} else {
return response()->json([
'status' => 'success',
'label' => trans('velocity::app.shop.general.alert.success'),
'message' => trans('velocity::app.customer.compare.already_added'),
], 200);
}
return response()->json([
'status' => 'success',
'message' => trans('velocity::app.customer.compare.added'),
'label' => trans('velocity::app.shop.general.alert.success'),
], $responseCode);
}
/**
@ -417,36 +446,36 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
public function deleteComparisonProduct()
{
// either delete all or individual
if (request()->get('slug') == 'all') {
if (request()->get('productId') == 'all') {
// delete all
$this->velocityCustomerDataRepository->update([
'compared_product' => json_encode([]),
$customerId = auth()->guard('customer')->user()->id;
$this->velocityCompareProductsRepository->deleteWhere([
'customer_id' => auth()->guard('customer')->user()->id,
]);
} else {
// delete individual
$customer = $this->velocityCustomerDataRepository->findOneByField([
$this->velocityCompareProductsRepository->deleteWhere([
'product_flat_id' => request()->get('productId'),
'customer_id' => auth()->guard('customer')->user()->id,
]);
$slug = request()->get('slug');
$comparedList = json_decode($customer->compared_product, true);
// $comparedList = json_decode($customer->compared_product, true);
$index = array_search($slug, $comparedList);
// $index = array_search($productId, $comparedList);
if ($index > -1) {
unset($comparedList[$index]);
// if ($index > -1) {
// unset($comparedList[$index]);
$this->velocityCustomerDataRepository->update([
'compared_product' => json_encode($comparedList),
], $customer->id);
}
// $this->velocityCustomerDataRepository->update([
// 'compared_product' => json_encode($comparedList),
// ], $customer->id);
// }
}
return $response = [
'status' => 'success',
return [
'status' => 'success',
'message' => trans('velocity::app.customer.compare.removed'),
'label' => trans('velocity::app.shop.general.alert.success'),
'label' => trans('velocity::app.shop.general.alert.success'),
];
}
}

View File

@ -4,9 +4,7 @@ namespace Webkul\Velocity\Models;
use Illuminate\Database\Eloquent\Model;
class VelocityCustomerData extends Model
class VelocityCustomerCompareProducts extends Model
{
protected $table = 'velocity_customer_data';
protected $guarded = [];
}

View File

@ -4,7 +4,7 @@ namespace Webkul\Velocity\Repositories;
use Webkul\Core\Eloquent\Repository;
class VelocityCustomerDataRepository extends Repository
class VelocityCustomerCompareProductsRepository extends Repository
{
/**
* Specify Model class name
@ -13,6 +13,6 @@ class VelocityCustomerDataRepository extends Repository
*/
function model()
{
return 'Webkul\Velocity\Models\VelocityCustomerData';
return 'Webkul\Velocity\Models\VelocityCustomerCompareProducts';
}
}

View File

@ -6,7 +6,7 @@
<script>
export default {
props: ['slug', 'customer'],
props: ['slug', 'customer', 'productId'],
data: function () {
return {}
@ -17,7 +17,7 @@
if (this.customer == "true") {
this.$http.put(
`${this.$root.baseUrl}/comparison`, {
slug: this.slug,
productId: this.productId,
}
).then(response => {
window.showAlert(`alert-${response.data.status}`, response.data.label, response.data.message);
@ -43,13 +43,13 @@
window.showAlert(
`alert-success`,
this.__('shop.general.alert.success'),
`${this.__('customer.compare.added')} <a href="${this.baseUrl}/comparison">compare</a>`
`${this.__('customer.compare.added')}`
);
} else {
window.showAlert(
`alert-success`,
this.__('shop.general.alert.success'),
`${this.__('customer.compare.already_added')} <a href="${this.baseUrl}/comparison">compare</a>`
`${this.__('customer.compare.already_added')}`
);
}
} else {
@ -58,7 +58,7 @@
window.showAlert(
`alert-success`,
this.__('shop.general.alert.success'),
`${this.__('customer.compare.added')} <a href="${this.baseUrl}/comparison">compare</a>`
`${this.__('customer.compare.added')}`
);
}
}

View File

@ -2264,4 +2264,13 @@
font-size: 24px !important
}
}
.material-icons {
&.cross {
top: 5px;
right: 20px;
cursor: pointer;
position: absolute;
}
}
}

View File

@ -6,8 +6,8 @@
@section('content-wrapper')
@php
$attributeModel = app('\Webkul\Attribute\Models\Attribute');
$comparableAttributes = $attributeModel->getComparableAttributes();
$attributeRepository = app('\Webkul\Attribute\Repositories\AttributeRepository');
$comparableAttributes = $attributeRepository->findByField('is_comparable', 1);
@endphp
<compare-product></compare-product>
@ -48,15 +48,20 @@
<span class="fs16">{{ $attribute['admin_name'] }}</span>
</div>
<div class="product-title col" :key="`title-${index}`" v-for="(product, index) in products">
<div class="col" :key="`title-${index}`" v-for="(product, index) in products">
@if ($attribute['code'] == 'name')
<h1 class="fw6 fs18" v-text="product['{{ $attribute['code'] }}']"></h1>
<a :href="`${$root.baseUrl}/${product.url_key}`" class="unset">
<h1 class="fw6 fs18" v-text="product['{{ $attribute['code'] }}']"></h1>
</a>
@elseif ($attribute['code'] == 'image')
<img :src="product['{{ $attribute['code'] }}']" class="image-wrapper"></span>
<a :href="`${$root.baseUrl}/${product.url_key}`" class="unset">
<img :src="product['{{ $attribute['code'] }}']" class="image-wrapper"></span>
</a>
@elseif ($attribute['code'] == 'price')
<span v-html="product['priceHTML']"></span>
@elseif ($attribute['code'] == 'addToCartHtml')
<span v-html="product['addToCartHtml']"></span>
<div v-html="product['addToCartHtml']"></div>
<i class="material-icons cross fs16" @click="removeProductCompare(isCustomer ? product.id : product.slug)">close</i>
@else
<span v-html="product['{{ $attribute['code'] }}']"></span>
@endif
@ -120,11 +125,15 @@
});
},
'removeProductCompare': function (slug) {
'removeProductCompare': function (productId) {
if (this.isCustomer) {
this.$http.delete(`${this.$root.baseUrl}/comparison?slug=${slug}`)
this.$http.delete(`${this.$root.baseUrl}/comparison?productId=${productId}`)
.then(response => {
this.$set(this, 'products', this.products.filter(product => product.slug != slug));
if (productId == 'all') {
this.$set(this, 'products', this.products.filter(product => false));
} else {
this.$set(this, 'products', this.products.filter(product => product.id != productId));
}
window.showAlert(`alert-${response.data.status}`, response.data.label, response.data.message);
})
@ -135,12 +144,12 @@
let existingItems = window.localStorage.getItem('compared_product');
existingItems = JSON.parse(existingItems);
if (slug == "all") {
if (productId == "all") {
updatedItems = [];
this.$set(this, 'products', []);
} else {
updatedItems = existingItems.filter(item => item != slug);
this.$set(this, 'products', this.products.filter(product => product.slug != slug));
updatedItems = existingItems.filter(item => item != productId);
this.$set(this, 'products', this.products.filter(product => product.slug != productId));
}
window.localStorage.setItem('compared_product', JSON.stringify(updatedItems));

View File

@ -19,9 +19,9 @@
$subMenuCollection['downloadables'] = $menuItem['children']['downloadables'];
$subMenuCollection['wishlist'] = $menuItem['children']['wishlist'];
$subMenuCollection['compare'] = [
'key' => 'account.compare',
'url' => route('velocity.product.compare'),
'name' => 'velocity::app.customer.compare.text',
'key' => 'account.compare',
'url' => route('velocity.product.compare'),
'name' => 'velocity::app.customer.compare.text',
];
$subMenuCollection['reviews'] = $menuItem['children']['reviews'];
$subMenuCollection['address'] = $menuItem['children']['address'];

View File

@ -52,11 +52,19 @@
@if (isset($showCompare) && $showCompare)
@auth('customer')
<compare-component slug="{{ $product->url_key }}" customer="true"></compare-component>
<compare-component
customer="true"
productId="{{ $product->id }}"
slug="{{ $product->url_key }}"
></compare-component>
@endif
@guest('customer')
<compare-component slug="{{ $product->url_key }}" customer="false"></compare-component>
<compare-component
customer="false"
productId="{{ $product->id }}"
slug="{{ $product->url_key }}"
></compare-component>
@endif
@endif

View File

@ -18,7 +18,7 @@
font-size: 18px;
font-weight: 600;
}
@media only screen and (max-width: 992px) {
.main-content-wrapper .vc-header {
box-shadow: unset;
@ -61,7 +61,7 @@
@endif
</div>
<div class="col-12">
<div class="col-12 no-padding">
<div class="hero-image">
@if (!is_null($category->image))
<img class="logo" src="{{ $category->image_url }}" />