new and featured products from ajax
This commit is contained in:
parent
fd4657f991
commit
c51cb168e8
|
|
@ -3761,6 +3761,10 @@ body::after {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cursor-not-allowed {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.cursor-default {
|
||||
cursor: default;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class CreateVelocityMetaData extends Migration
|
|||
$table->boolean('slider')->default(0);
|
||||
$table->json('advertisement')->nullable();
|
||||
$table->integer('sidebar_category_count')->default(9);
|
||||
$table->integer('featured_product_count')->default(4);
|
||||
$table->integer('new_products_count')->default(4);
|
||||
$table->integer('featured_product_count')->default(10);
|
||||
$table->integer('new_products_count')->default(10);
|
||||
$table->text('subscription_bar_content')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -104,45 +104,56 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
|
||||
public function categoryDetails()
|
||||
{
|
||||
$categoryDetails = app('Webkul\Category\Repositories\CategoryRepository')->findByPath(request()->get('category-slug'));
|
||||
$slug = request()->get('category-slug');
|
||||
|
||||
if ($categoryDetails) {
|
||||
$list = false;
|
||||
$customizedProducts = [];
|
||||
$products = $this->productRepository->getAll($categoryDetails->id);
|
||||
switch ($slug) {
|
||||
case 'new-products':
|
||||
case 'featured-products':
|
||||
$formattedProducts = [];
|
||||
$count = request()->get('count');
|
||||
|
||||
foreach ($products as $product) {
|
||||
$productRepository = app('Webkul\Velocity\Repositories\Product\ProductRepository');
|
||||
|
||||
$productImage = app('Webkul\Product\Helpers\ProductImage')->getProductBaseImage($product)['medium_image_url'];
|
||||
if ($slug == "new-products") {
|
||||
$products = $productRepository->getNewProducts($count);
|
||||
} else if ($slug == "featured-products") {
|
||||
$products = $productRepository->getFeaturedProducts($count);
|
||||
}
|
||||
|
||||
$reviewHelper = app('Webkul\Product\Helpers\Review');
|
||||
foreach ($products as $product) {
|
||||
array_push($formattedProducts, $this->formatProduct($product));
|
||||
}
|
||||
|
||||
$totalReviews = $reviewHelper->getTotalReviews($product);
|
||||
$avgRatings = ceil($reviewHelper->getAverageRating($product));
|
||||
$response = [
|
||||
'status' => true,
|
||||
'products' => $formattedProducts,
|
||||
];
|
||||
|
||||
array_push($customizedProducts, [
|
||||
'list' => false,
|
||||
'name' => $product->name,
|
||||
'image' => $productImage,
|
||||
'slug' => $product->url_key,
|
||||
'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,
|
||||
'addWishlistClass' => !(isset($list) && $list) ? 'col-lg-4 col-md-4 col-sm-12 offset-lg-4 pr0' : '',
|
||||
'addToCartBtnClass' => !(isset($list) && $list) ? $addToCartBtnClass ?? '' : ''
|
||||
])->render(),
|
||||
]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$categoryDetails = app('Webkul\Category\Repositories\CategoryRepository')->findByPath($slug);
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'list' => $list,
|
||||
'categoryDetails' => $categoryDetails,
|
||||
'categoryProducts' => $customizedProducts,
|
||||
];
|
||||
if ($categoryDetails) {
|
||||
$list = false;
|
||||
$customizedProducts = [];
|
||||
$products = $this->productRepository->getAll($categoryDetails->id);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$productDetails = [];
|
||||
|
||||
array_push($productDetails, $this->formatProduct($product));
|
||||
array_push($customizedProducts, $productDetails);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'list' => $list,
|
||||
'categoryDetails' => $categoryDetails,
|
||||
'categoryProducts' => $customizedProducts,
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $response ?? [
|
||||
|
|
@ -150,13 +161,6 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
];
|
||||
}
|
||||
|
||||
public function newOrFeaturedProducts($slug, $count = 10)
|
||||
{
|
||||
$products = app('Webkul\Velocity\Repositories\Product\ProductRepository')->getNewProducts($count);
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
public function fetchCategories()
|
||||
{
|
||||
$formattedCategories = [];
|
||||
|
|
@ -187,4 +191,27 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
'category_icon_path' => $category->category_icon_path,
|
||||
];
|
||||
}
|
||||
|
||||
private function formatProduct($product, $list = false)
|
||||
{
|
||||
$reviewHelper = app('Webkul\Product\Helpers\Review');
|
||||
$totalReviews = $reviewHelper->getTotalReviews($product);
|
||||
$avgRatings = ceil($reviewHelper->getAverageRating($product));
|
||||
$productImage = app('Webkul\Product\Helpers\ProductImage')->getProductBaseImage($product)['medium_image_url'];
|
||||
|
||||
return [
|
||||
'name' => $product->name,
|
||||
'image' => $productImage,
|
||||
'slug' => $product->url_key,
|
||||
'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,
|
||||
'addWishlistClass' => !(isset($list) && $list) ? 'col-lg-4 col-md-4 col-sm-12 offset-lg-4 pr0' : '',
|
||||
'addToCartBtnClass' => !(isset($list) && $list) ? $addToCartBtnClass ?? '' : ''
|
||||
])->render(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,9 @@
|
|||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.cursor-not-allowed {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.cursor-default {
|
||||
cursor: default;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@
|
|||
v-else
|
||||
@mouseout="toggleSidebar('0', $event, 'mouseout')"
|
||||
@mouseover="toggleSidebar('0', $event, 'mouseover')"
|
||||
class="main-category fs16 unselectable fw6 cursor-pointer left">
|
||||
:class="`main-category fs16 unselectable fw6 ${(sharedRootCategories.length > 0) ? 'cursor-pointer' : 'cursor-not-allowed'} left`">
|
||||
|
||||
<i class="rango-view-list text-down-4 align-vertical-top fs18">
|
||||
</i>
|
||||
|
|
@ -667,9 +667,9 @@
|
|||
|
||||
data: function () {
|
||||
return {
|
||||
'currencies': false,
|
||||
'languages': false,
|
||||
'hamburger': false,
|
||||
'currencies': false,
|
||||
'subCategory': null,
|
||||
'isSearchbar': false,
|
||||
'rootCategories': true,
|
||||
|
|
|
|||
|
|
@ -1,51 +1,83 @@
|
|||
@php
|
||||
$count = $velocityMetaData ? $velocityMetaData->featured_product_count : 10;
|
||||
|
||||
$featuredProducts = app('Webkul\Velocity\Repositories\Product\ProductRepository')->getFeaturedProducts($count);
|
||||
|
||||
$featuredProductsCount = $featuredProducts->count();
|
||||
@endphp
|
||||
|
||||
@if ($featuredProductsCount)
|
||||
<featured-products></featured-products>
|
||||
|
||||
<div class="container-fluid featured-products">
|
||||
<card-list-header heading="{{ __('shop::app.home.featured-products') }}">
|
||||
</card-list-header>
|
||||
|
||||
<div class="carousel-products vc-full-screen">
|
||||
<carousel-component
|
||||
slides-per-page="6"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="fearured-products-carousel"
|
||||
:slides-count="{{ $featuredProductsCount }}">
|
||||
|
||||
@foreach ($featuredProducts as $index => $product)
|
||||
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', ['product' => $product])
|
||||
@push('scripts')
|
||||
<script type="text/x-template" id="featured-products-template">
|
||||
<div class="container-fluid featured-products" v-if="featuredProducts.length > 0">
|
||||
<card-list-header heading="{{ __('shop::app.home.featured-products') }}">
|
||||
</card-list-header>
|
||||
|
||||
<div class="carousel-products vc-full-screen">
|
||||
<carousel-component
|
||||
slides-per-page="6"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="fearured-products-carousel"
|
||||
:slides-count="featuredProducts.length">
|
||||
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in featuredProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
|
||||
@endforeach
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="carousel-products vc-small-screen">
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="fearured-products-carousel"
|
||||
:slides-count="{{ $featuredProductsCount }}">
|
||||
|
||||
@foreach ($featuredProducts as $index => $product)
|
||||
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', ['product' => $product])
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="carousel-products vc-small-screen">
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="fearured-products-carousel"
|
||||
:slides-count="featuredProducts.length">
|
||||
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in featuredProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
|
||||
@endforeach
|
||||
</carousel-component>
|
||||
</carousel-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(() => {
|
||||
Vue.component('featured-products', {
|
||||
'template': '#featured-products-template',
|
||||
data: function () {
|
||||
return {
|
||||
'list': false,
|
||||
'featuredProducts': [],
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.getFeaturedProducts();
|
||||
},
|
||||
|
||||
methods: {
|
||||
'getFeaturedProducts': function () {
|
||||
this.$http.get(`${this.baseUrl}/category-details?category-slug=featured-products&count={{ $count }}`)
|
||||
.then(response => {
|
||||
if (response.data.status)
|
||||
this.featuredProducts = response.data.products;
|
||||
})
|
||||
.catch(error => {})
|
||||
}
|
||||
}
|
||||
})
|
||||
})()
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
|
|
@ -1,112 +1,147 @@
|
|||
@php
|
||||
$count = $velocityMetaData ? $velocityMetaData->new_products_count : 10;
|
||||
|
||||
$newProducts = app('Webkul\Velocity\Repositories\Product\ProductRepository')->getNewProducts($count);
|
||||
@endphp
|
||||
|
||||
@if (! empty($newProducts) && $newProducts->total())
|
||||
<div class="container-fluid">
|
||||
<card-list-header heading="{{ __('shop::app.home.new-products') }}">
|
||||
</card-list-header>
|
||||
<new-products></new-products>
|
||||
|
||||
{!! view_render_event('bagisto.shop.new-products.before') !!}
|
||||
@push('scripts')
|
||||
<script type="text/x-template" id="new-products-template">
|
||||
<div v-if="newProducts.length > 0">
|
||||
<div class="container-fluid">
|
||||
<card-list-header heading="{{ __('shop::app.home.new-products') }}">
|
||||
</card-list-header>
|
||||
|
||||
{!! view_render_event('bagisto.shop.new-products.before') !!}
|
||||
|
||||
@if ($showRecentlyViewed)
|
||||
@push('css')
|
||||
<style>
|
||||
.recently-viewed {
|
||||
padding-right: 0px;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
<div class="row">
|
||||
<div class="col-9 no-padding carousel-products vc-full-screen" v-if="!isMobile()">
|
||||
<carousel-component
|
||||
slides-per-page="5"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="newProducts.length">
|
||||
|
||||
@if ($showRecentlyViewed)
|
||||
@push('css')
|
||||
<style>
|
||||
.recently-viewed {
|
||||
padding-right: 0px;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
<div class="row">
|
||||
<div class="col-9 no-padding carousel-products vc-full-screen" v-if="!isMobile()">
|
||||
<carousel-component
|
||||
slides-per-page="5"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="{{ sizeof($newProducts) }}">
|
||||
|
||||
@foreach ($newProducts as $index => $product)
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', [
|
||||
'product' => $product,
|
||||
'addToCartBtnClass' => 'small-padding'
|
||||
])
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in newProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="col-12 no-padding carousel-products vc-small-screen" v-else>
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="newProducts.length">
|
||||
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in newProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
@include ('shop::products.list.recently-viewed', [
|
||||
'quantity' => 3,
|
||||
'addClass' => 'col-lg-3 col-md-12',
|
||||
'addClassWrapper' => 'scrollable max-height-350',
|
||||
])
|
||||
</div>
|
||||
@else
|
||||
<div class="carousel-products vc-full-screen">
|
||||
<carousel-component
|
||||
slides-per-page="6"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="newProducts.length">
|
||||
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in newProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
@endforeach
|
||||
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="col-12 no-padding carousel-products vc-small-screen" v-else>
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="{{ sizeof($newProducts) }}">
|
||||
|
||||
@foreach ($newProducts as $index => $product)
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', [
|
||||
'product' => $product,
|
||||
'addToCartBtnClass' => 'small-padding'
|
||||
])
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="carousel-products vc-small-screen">
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="newProducts.length">
|
||||
|
||||
<slide
|
||||
:key="index"
|
||||
:slot="`slide-${index}`"
|
||||
v-for="(product, index) in newProducts">
|
||||
<product-card
|
||||
:list="list"
|
||||
:product="product">
|
||||
</product-card>
|
||||
</slide>
|
||||
@endforeach
|
||||
</carousel-component>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.new-products.after') !!}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
</carousel-component>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(() => {
|
||||
Vue.component('new-products', {
|
||||
'template': '#new-products-template',
|
||||
data: function () {
|
||||
return {
|
||||
'list': false,
|
||||
'newProducts': [],
|
||||
}
|
||||
},
|
||||
|
||||
@include ('shop::products.list.recently-viewed', [
|
||||
'quantity' => 3,
|
||||
'addClass' => 'col-lg-3 col-md-12',
|
||||
'addClassWrapper' => 'scrollable max-height-350',
|
||||
])
|
||||
</div>
|
||||
@else
|
||||
<div class="carousel-products vc-full-screen">
|
||||
<carousel-component
|
||||
slides-per-page="6"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="{{ sizeof($newProducts) }}">
|
||||
mounted: function () {
|
||||
this.getNewProducts();
|
||||
},
|
||||
|
||||
@foreach ($newProducts as $index => $product)
|
||||
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', ['product' => $product])
|
||||
</slide>
|
||||
|
||||
@endforeach
|
||||
|
||||
</carousel-component>
|
||||
</div>
|
||||
|
||||
<div class="carousel-products vc-small-screen">
|
||||
<carousel-component
|
||||
slides-per-page="2"
|
||||
navigation-enabled="hide"
|
||||
pagination-enabled="hide"
|
||||
id="new-products-carousel"
|
||||
:slides-count="{{ sizeof($newProducts) }}">
|
||||
|
||||
@foreach ($newProducts as $index => $product)
|
||||
<slide slot="slide-{{ $index }}">
|
||||
@include ('shop::products.list.card', [
|
||||
'product' => $product,
|
||||
'addToCartBtnClass' => 'small-padding'
|
||||
])
|
||||
</slide>
|
||||
@endforeach
|
||||
</carousel-component>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.new-products.after') !!}
|
||||
</div>
|
||||
@endif
|
||||
methods: {
|
||||
'getNewProducts': function () {
|
||||
this.$http.get(`${this.baseUrl}/category-details?category-slug=new-products&count={{ $count }}`)
|
||||
.then(response => {
|
||||
if (response.data.status)
|
||||
this.newProducts = response.data.products
|
||||
})
|
||||
.catch(error => {})
|
||||
}
|
||||
}
|
||||
})
|
||||
})()
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -1,26 +1,30 @@
|
|||
@inject ('productViewHelper', 'Webkul\Product\Helpers\View')
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.view.attributes.before', ['product' => $product]) !!}
|
||||
@php
|
||||
$customAttributeValues = $productViewHelper->getAdditionalData($product);
|
||||
@endphp
|
||||
|
||||
@if ($customAttributeValues = $productViewHelper->getAdditionalData($product))
|
||||
<accordian :title="'{{ __('shop::app.products.specification') }}'" :active="'{{ $active }}' == true ? true : false">
|
||||
<div slot="header">
|
||||
<h3 class="no-margin display-inbl">
|
||||
{{ __('velocity::app.products.more-infomation') }}
|
||||
</h3>
|
||||
<i class="rango-arrow"></i>
|
||||
</div>
|
||||
@if ($customAttributeValues && $customAttributeValues[0]['value'])
|
||||
<accordian :title="'{{ __('shop::app.products.specification') }}'" :active="'{{ $active }}' == true ? true : false">
|
||||
<div slot="header">
|
||||
<h3 class="no-margin display-inbl">
|
||||
{{ __('velocity::app.products.more-infomation') }}
|
||||
</h3>
|
||||
<i class="rango-arrow"></i>
|
||||
</div>
|
||||
|
||||
<div slot="body">
|
||||
<table class="full-specifications">
|
||||
<div slot="body">
|
||||
<table class="full-specifications">
|
||||
|
||||
@foreach ($customAttributeValues as $attribute)
|
||||
<tr>
|
||||
@if ($attribute['label'])
|
||||
<td class='fw6'>{{ $attribute['label'] }}</td>
|
||||
@else
|
||||
<td>{{ $attribute['admin_name'] }}</td>
|
||||
@endif
|
||||
|
||||
@foreach ($customAttributeValues as $attribute)
|
||||
<tr>
|
||||
@if ($attribute['label'])
|
||||
<td class='fw6'>{{ $attribute['label'] }}</td>
|
||||
@else
|
||||
<td>{{ $attribute['admin_name'] }}</td>
|
||||
@endif
|
||||
@if ($attribute['type'] == 'file' && $attribute['value'])
|
||||
<td>
|
||||
<a href="{{ route('shop.product.file.download', [$product->product_id, $attribute['id']])}}">
|
||||
|
|
@ -36,12 +40,11 @@
|
|||
@else
|
||||
<td>{{ $attribute['value'] }}</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</accordian>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</accordian>
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.view.attributes.after', ['product' => $product]) !!}
|
||||
Loading…
Reference in New Issue