parent
46ad282d2f
commit
8d167c7b76
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"/js/velocity.js": "/js/velocity.js?id=e4fc11168131a639028b",
|
||||
"/js/velocity.js": "/js/velocity.js?id=6ddbe8cf2f5f023bf2af",
|
||||
"/css/velocity-admin.css": "/css/velocity-admin.css?id=612d35e452446366eef7",
|
||||
"/css/velocity.css": "/css/velocity.css?id=d12aae8c42eea4e2829b"
|
||||
"/css/velocity.css": "/css/velocity.css?id=3d8d4648fa70ccf81482"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@ namespace Webkul\Velocity\Helpers;
|
|||
use DB;
|
||||
use Webkul\Product\Helpers\Review;
|
||||
use Webkul\Product\Models\Product as ProductModel;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Product\Repositories\ProductFlatRepository;
|
||||
use Webkul\Velocity\Repositories\OrderBrandsRepository;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository;
|
||||
use Webkul\Velocity\Repositories\VelocityMetadataRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository as ProductRepository;
|
||||
|
||||
class Helper extends Review
|
||||
{
|
||||
|
|
@ -21,12 +22,19 @@ class Helper extends Review
|
|||
protected $orderBrands;
|
||||
|
||||
/**
|
||||
* productRepository object
|
||||
* \Webkul\Product\Repositories\ProductRepository object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* \Webkul\Product\Repositories\ProductFlatRepository object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $productFlatRepository;
|
||||
|
||||
/**
|
||||
* productModel object
|
||||
*
|
||||
|
|
@ -59,6 +67,7 @@ class Helper extends Review
|
|||
ProductModel $productModel,
|
||||
ProductRepository $productRepository,
|
||||
AttributeOptionRepository $attributeOption,
|
||||
ProductFlatRepository $productFlatRepository,
|
||||
OrderBrandsRepository $orderBrandsRepository,
|
||||
ProductReviewRepository $productReviewRepository,
|
||||
VelocityMetadataRepository $velocityMetadataRepository
|
||||
|
|
@ -66,6 +75,7 @@ class Helper extends Review
|
|||
$this->productModel = $productModel;
|
||||
$this->attributeOption = $attributeOption;
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productFlatRepository = $productFlatRepository;
|
||||
$this->orderBrandsRepository = $orderBrandsRepository;
|
||||
$this->productReviewRepository = $productReviewRepository;
|
||||
$this->velocityMetadataRepository = $velocityMetadataRepository;
|
||||
|
|
@ -232,7 +242,7 @@ class Helper extends Review
|
|||
$avgRatings = ceil($reviewHelper->getAverageRating($product));
|
||||
|
||||
$galleryImages = $productImageHelper->getGalleryImages($product);
|
||||
$productImage = $productImageHelper->getProductBaseImage($product)['medium_image_url'];
|
||||
$productImage = $productImageHelper->getProductBaseImage($product)['large_image_url'];
|
||||
|
||||
return [
|
||||
'avgRating' => $avgRatings,
|
||||
|
|
@ -257,30 +267,37 @@ class Helper extends Review
|
|||
/**
|
||||
* Returns the count rating of the product
|
||||
*
|
||||
* @param $items - & seperated product slugs
|
||||
* @param $items
|
||||
* @param $separator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
*/
|
||||
public function fetchProductCollection($items, $separator='&')
|
||||
{
|
||||
$productCollection = [];
|
||||
$productSlugs = explode($separator, $items);
|
||||
$productIds = explode($separator, $items);
|
||||
|
||||
foreach ($productSlugs as $slug) {
|
||||
$product = $this->productRepository->findBySlug($slug);
|
||||
foreach ($productIds as $productId) {
|
||||
// @TODO:- query only once insted of 2
|
||||
$productFlat = $this->productFlatRepository->findOneWhere(['id' => $productId]);
|
||||
|
||||
if ($product) {
|
||||
$formattedProduct = $this->formatProduct($product);
|
||||
if ($productFlat) {
|
||||
$product = $this->productRepository->findOneWhere(['id' => $productFlat->product_id]);
|
||||
|
||||
$productMetaDetails = [];
|
||||
$productMetaDetails['image'] = $formattedProduct['image'];
|
||||
$productMetaDetails['priceHTML'] = $formattedProduct['priceHTML'];
|
||||
$productMetaDetails['addToCartHtml'] = $formattedProduct['addToCartHtml'];
|
||||
$productMetaDetails['galleryImages'] = $formattedProduct['galleryImages'];
|
||||
if ($product) {
|
||||
$formattedProduct = $this->formatProduct($product);
|
||||
|
||||
$product = array_merge($product->toArray(), $productMetaDetails);
|
||||
$productMetaDetails = [];
|
||||
$productMetaDetails['slug'] = $product->url_key;
|
||||
$productMetaDetails['image'] = $formattedProduct['image'];
|
||||
$productMetaDetails['priceHTML'] = $formattedProduct['priceHTML'];
|
||||
$productMetaDetails['addToCartHtml'] = $formattedProduct['addToCartHtml'];
|
||||
$productMetaDetails['galleryImages'] = $formattedProduct['galleryImages'];
|
||||
|
||||
array_push($productCollection, $product);
|
||||
$product = array_merge($product->toArray(), $productMetaDetails);
|
||||
|
||||
array_push($productCollection, $product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ShopController extends Controller
|
|||
* Index to handle the view loaded with the search results
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$results = $this->velocityProductRepository->searchProductsFromCategory(request()->all());
|
||||
|
|
@ -67,16 +67,14 @@ class ShopController extends Controller
|
|||
$formattedProducts = [];
|
||||
$count = request()->get('count');
|
||||
|
||||
$productRepository = app('Webkul\Velocity\Repositories\Product\ProductRepository');
|
||||
|
||||
if ($slug == "new-products") {
|
||||
$products = $productRepository->getNewProducts($count);
|
||||
$products = $this->velocityProductRepository->getNewProducts($count);
|
||||
} else if ($slug == "featured-products") {
|
||||
$products = $productRepository->getFeaturedProducts($count);
|
||||
$products = $this->velocityProductRepository->getFeaturedProducts($count);
|
||||
}
|
||||
|
||||
foreach ($products as $product) {
|
||||
array_push($formattedProducts, $this->formatProduct($product));
|
||||
array_push($formattedProducts, $this->velocityHelper->formatProduct($product));
|
||||
}
|
||||
|
||||
$response = [
|
||||
|
|
@ -96,7 +94,7 @@ class ShopController extends Controller
|
|||
foreach ($products as $product) {
|
||||
$productDetails = [];
|
||||
|
||||
$productDetails = array_merge($productDetails, $this->formatProduct($product));
|
||||
$productDetails = array_merge($productDetails, $this->velocityHelper->formatProduct($product));
|
||||
array_push($customizedProducts, $productDetails);
|
||||
}
|
||||
|
||||
|
|
@ -164,37 +162,6 @@ class ShopController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
private function formatProduct($product, $list = false)
|
||||
{
|
||||
$reviewHelper = app('Webkul\Product\Helpers\Review');
|
||||
|
||||
$totalReviews = $reviewHelper->getTotalReviews($product);
|
||||
|
||||
$avgRatings = ceil($reviewHelper->getAverageRating($product));
|
||||
|
||||
$galleryImages = $this->productImageHelper->getGalleryImages($product);
|
||||
$productImage = $this->productImageHelper->getProductBaseImage($product)['medium_image_url'];
|
||||
|
||||
return [
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getWishlistList()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
|
|
@ -204,7 +171,7 @@ class ShopController extends Controller
|
|||
* this function will provide the count of wishlist and comparison for logged in user
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
*/
|
||||
public function getItemsCount()
|
||||
{
|
||||
if ($customer = auth()->guard('customer')->user()) {
|
||||
|
|
@ -232,10 +199,8 @@ class ShopController extends Controller
|
|||
/**
|
||||
* this function will provide details of multiple product
|
||||
*
|
||||
* @param $productIds
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
*/
|
||||
public function getDetailedProducts()
|
||||
{
|
||||
// for product details
|
||||
|
|
|
|||
|
|
@ -25,16 +25,14 @@
|
|||
);
|
||||
});
|
||||
} else {
|
||||
let updatedItems = [this.slug];
|
||||
let existingItems = window.localStorage.getItem('compared_product');
|
||||
let updatedItems = [this.productId];
|
||||
let existingItems = this.getStorageValue('compared_product');
|
||||
|
||||
if (existingItems) {
|
||||
existingItems = JSON.parse(existingItems);
|
||||
if (existingItems.indexOf(this.productId) == -1) {
|
||||
updatedItems = existingItems.concat(updatedItems);
|
||||
|
||||
if (existingItems.indexOf(this.slug) == -1) {
|
||||
updatedItems = existingItems.concat([this.slug]);
|
||||
|
||||
window.localStorage.setItem('compared_product', JSON.stringify(updatedItems));
|
||||
this.setStorageValue('compared_product', updatedItems);
|
||||
|
||||
window.showAlert(
|
||||
`alert-success`,
|
||||
|
|
@ -49,7 +47,7 @@
|
|||
);
|
||||
}
|
||||
} else {
|
||||
window.localStorage.setItem('compared_product', JSON.stringify([this.slug]));
|
||||
this.setStorageValue('compared_product', updatedItems);
|
||||
|
||||
window.showAlert(
|
||||
`alert-success`,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@
|
|||
|
||||
<p class="pt14 fs14 description-text" v-html="product.shortDescription"></p>
|
||||
|
||||
<vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
|
||||
<div class="product-actions">
|
||||
<vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<a
|
||||
v-else
|
||||
@click="toggleProductWishlist(productSlug)"
|
||||
@click="toggleProductWishlist(productId)"
|
||||
:class="`unset wishlist-icon ${addClass ? addClass : ''} text-right`">
|
||||
|
||||
<i
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
'active',
|
||||
'addClass',
|
||||
'addedText',
|
||||
'productId',
|
||||
'removeText',
|
||||
'isCustomer',
|
||||
'productSlug',
|
||||
|
|
@ -43,21 +44,21 @@
|
|||
|
||||
created: function () {
|
||||
if (this.isCustomer == 'false') {
|
||||
this.isActive = this.isWishlisted(this.productSlug);
|
||||
this.isActive = this.isWishlisted(this.productId);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggleProductWishlist: function (productSlug) {
|
||||
var updatedValue = [productSlug];
|
||||
toggleProductWishlist: function (productId) {
|
||||
var updatedValue = [productId];
|
||||
let existingValue = this.getStorageValue('wishlist_product');
|
||||
|
||||
if (existingValue) {
|
||||
let valueIndex = existingValue.indexOf(productSlug);
|
||||
let valueIndex = existingValue.indexOf(productId);
|
||||
|
||||
if (valueIndex == -1) {
|
||||
this.isActive = true;
|
||||
existingValue.push(productSlug);
|
||||
existingValue.push(productId);
|
||||
} else {
|
||||
this.isActive = false;
|
||||
existingValue.splice(valueIndex, 1);
|
||||
|
|
@ -80,11 +81,11 @@
|
|||
return true;
|
||||
},
|
||||
|
||||
isWishlisted: function (productSlug) {
|
||||
isWishlisted: function (productId) {
|
||||
let existingValue = this.getStorageValue('wishlist_product');
|
||||
|
||||
if (existingValue) {
|
||||
return ! (existingValue.indexOf(productSlug) == -1);
|
||||
return ! (existingValue.indexOf(productId) == -1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -634,6 +634,31 @@ body::after {
|
|||
}
|
||||
}
|
||||
|
||||
.product-actions {
|
||||
display: inline-block;
|
||||
|
||||
.compare-icon,
|
||||
.wishlist-icon {
|
||||
height: 38px;
|
||||
display: inline-table;
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
|
||||
i {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.wishlist-icon {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.add-to-cart-btn {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.product-price {
|
||||
span:nth-child(1),
|
||||
.special-price,
|
||||
|
|
@ -643,19 +668,6 @@ body::after {
|
|||
}
|
||||
}
|
||||
|
||||
.compare-icon,
|
||||
.wishlist-icon {
|
||||
height: 38px;
|
||||
display: table;
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
|
||||
i {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.quick-view-name {
|
||||
font-size: 24px;
|
||||
line-height: 25px;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@
|
|||
|
||||
methods: {
|
||||
'getComparedProducts': function () {
|
||||
let items = '';
|
||||
let url = `${this.$root.baseUrl}/${this.isCustomer ? 'comparison' : 'detailed-products'}`;
|
||||
|
||||
let data = {
|
||||
|
|
@ -139,7 +140,7 @@
|
|||
}
|
||||
|
||||
if (! this.isCustomer) {
|
||||
let items = this.getStorageValue('compared_product');
|
||||
items = this.getStorageValue('compared_product');
|
||||
items = items ? items.join('&') : '';
|
||||
|
||||
data = {
|
||||
|
|
@ -149,14 +150,19 @@
|
|||
};
|
||||
}
|
||||
|
||||
this.$http.get(url, data)
|
||||
.then(response => {
|
||||
if (this.isCustomer || (! this.isCustomer && items != "")) {
|
||||
this.$http.get(url, data)
|
||||
.then(response => {
|
||||
this.isProductListLoaded = true;
|
||||
this.products = response.data.products;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
} else {
|
||||
this.isProductListLoaded = true;
|
||||
this.products = response.data.products;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
'removeProductCompare': function (productId) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<wishlist-component
|
||||
active="false"
|
||||
is-customer="false"
|
||||
product-id="{{ $product->id }}"
|
||||
product-slug="{{ $product->url_key }}"
|
||||
add-class="{{ $addWishlistClass ?? '' }}"
|
||||
added-text="{{ __('shop::app.customer.account.wishlist.add') }}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue