Resolved conflicts

This commit is contained in:
Jitendra Singh 2020-03-06 16:02:52 +05:30
commit 010ae65691
40 changed files with 951 additions and 475 deletions

View File

@ -4,10 +4,10 @@ APP_VERSION=1.0.0
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=
APP_LOCALE=
APP_TIMEZONE=Asia/Kolkata
APP_LOCALE=en
LOG_CHANNEL=stack
APP_CURRENCY=
APP_CURRENCY=USD
DB_CONNECTION=mysql
DB_HOST=127.0.0.1

View File

@ -21,13 +21,9 @@ class ProductDataGrid extends DataGrid
{
parent::__construct();
$this->locale = request()->get('locale') == 'all'
? app()->getLocale()
: (request()->get('locale') ?? app()->getLocale());
$this->locale = request()->get('locale') ?? 'all';
$this->channel = request()->get('channel') == 'all'
? core()->getDefaultChannelCode()
: (request()->get('channel') ?? core()->getDefaultChannelCode());
$this->channel = request()->get('channel') ?? 'all';
}
public function prepareQueryBuilder()
@ -45,7 +41,17 @@ class ProductDataGrid extends DataGrid
'product_flat.price',
'attribute_families.name as attribute_family',
DB::raw('SUM(DISTINCT ' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')
)->where('locale', $this->locale)->where('locale', $this->locale);
);
if ($this->locale !== 'all') {
$queryBuilder->where('locale', $this->locale);
} else {
$queryBuilder->whereNotNull('product_flat.name');
}
if ($this->channel !== 'all') {
$queryBuilder->where('channel', $this->channel);
}
$queryBuilder->groupBy('product_flat.product_id');

View File

@ -213,6 +213,14 @@
</select>
</div>
<div class="control-group">
<label for="is_comparable">{{ __('admin::app.catalog.attributes.is_comparable') }}</label>
<select class="control" id="is_comparable" name="is_comparable">
<option value="0">{{ __('admin::app.catalog.attributes.no') }}</option>
<option value="1">{{ __('admin::app.catalog.attributes.yes') }}</option>
</select>
</div>
{!! view_render_event('bagisto.admin.catalog.attribute.create_form_accordian.configuration.controls.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" @click="redirectBack('{{ url('/admin/dashboard') }}')"></i>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.cms.pages.add-title') }}
</h1>

View File

@ -13,7 +13,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" @click="redirectBack('{{ url('/admin/dashboard') }}')"></i>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.cms.pages.edit-title') }}
</h1>

View File

@ -15,6 +15,7 @@ class ChannelTableSeeder extends Seeder
'id' => 1,
'code' => 'default',
'name' => 'Default',
'theme' => 'velocity',
'root_category_id' => 1,
'home_page_content' => '<p>@include("shop::home.slider") @include("shop::home.featured-products") @include("shop::home.new-products")</p><div class="banner-container"><div class="left-banner"><img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581f9494b8a1.png" /></div><div class="right-banner"><img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581fb045cf02.png" /> <img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581fc352d803.png" /></div></div>',
'footer_content' => '<div class="list-container"><span class="list-heading">Quick Links</span><ul class="list-group"><li><a href="@php echo route(\'shop.cms.page\', \'about-us\') @endphp">About Us</a></li><li><a href="@php echo route(\'shop.cms.page\', \'return-policy\') @endphp">Return Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'refund-policy\') @endphp">Refund Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-conditions\') @endphp">Terms and conditions</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-of-use\') @endphp">Terms of Use</a></li><li><a href="@php echo route(\'shop.cms.page\', \'contact-us\') @endphp">Contact Us</a></li></ul></div><div class="list-container"><span class="list-heading">Connect With Us</span><ul class="list-group"><li><a href="#"><span class="icon icon-facebook"></span>Facebook </a></li><li><a href="#"><span class="icon icon-twitter"></span> Twitter </a></li><li><a href="#"><span class="icon icon-instagram"></span> Instagram </a></li><li><a href="#"> <span class="icon icon-google-plus"></span>Google+ </a></li><li><a href="#"> <span class="icon icon-linkedin"></span>LinkedIn </a></li></ul></div>',

View File

@ -0,0 +1,3 @@
<script>
window.location.href = window.location.href.replace('/guest-wishlist', '');
</script>

View File

@ -7,8 +7,10 @@
target.value = e.target.value.toString()
.toLowerCase()
.normalize('NFKD') // Normalize Unicode
.replace(/[^\w- ]+/g, '')
// replace whitespaces with dashes
.replace(/ +/g, '-')
@ -21,4 +23,4 @@
el.addEventListener('input', handler);
}
}
</script>
</script>

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=edb24f7ab80594df62df",
"/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=0c3bbabfcb61f4640459"
"/css/velocity.css": "/css/velocity.css?id=84682d653fd625fc680a"
}

View File

@ -5,9 +5,10 @@ namespace Webkul\Velocity\Helpers;
use Illuminate\Support\Facades\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\Attribute\Repositories\AttributeOptionRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Product\Repositories\ProductReviewRepository;
use Webkul\Velocity\Repositories\VelocityMetadataRepository;
@ -28,13 +29,20 @@ class Helper extends Review
protected $orderBrandsRepository;
/**
* productRepository object
* ProductRepository object
*
* @var object
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* ProductFlatRepository object
*
* @var \Webkul\Product\Repositories\ProductFlatRepository
*/
protected $productFlatRepository;
/**
* productModel object
*
* @var \Webkul\Attribute\Repositories\AttributeOptionRepository
@ -68,7 +76,8 @@ class Helper extends Review
public function __construct(
ProductModel $productModel,
ProductRepository $productRepository,
AttributeOptionRepository $attributeOptionRepository,
AttributeOptionRepository $attributeOption,
ProductFlatRepository $productFlatRepository,
OrderBrandsRepository $orderBrandsRepository,
ProductReviewRepository $productReviewRepository,
VelocityMetadataRepository $velocityMetadataRepository
@ -79,6 +88,8 @@ class Helper extends Review
$this->productRepository = $productRepository;
$this->productFlatRepository = $productFlatRepository;
$this->orderBrandsRepository = $orderBrandsRepository;
$this->productReviewRepository = $productReviewRepository;
@ -279,6 +290,18 @@ class Helper extends Review
$galleryImages = $productImageHelper->getGalleryImages($product);
$productImage = $productImageHelper->getProductBaseImage($product)['medium_image_url'];
$largeProductImageName = "large-product-placeholder.png";
$mediumProductImageName = "meduim-product-placeholder.png";
if (strpos($productImage, $mediumProductImageName) > -1) {
$productImageNameCollection = explode('/', $productImage);
$productImageName = $productImageNameCollection[sizeof($productImageNameCollection) - 1];
if ($productImageName == $mediumProductImageName) {
$productImage = str_replace($mediumProductImageName, $largeProductImageName, $productImage);
}
}
return [
'avgRating' => $avgRatings,
'totalReviews' => $totalReviews,
@ -291,12 +314,51 @@ class Helper extends Review
'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,
'product' => $product,
'addWishlistClass' => ! (isset($list) && $list) ? '' : '',
'addToCartBtnClass' => ! (isset($list) && $list) ? 'small-padding' : '',
])->render(),
];
}
}
/**
* Returns the count rating of the product
*
* @param $items
* @param $separator
*
* @return array
*/
public function fetchProductCollection($items, $separator='&')
{
$productCollection = [];
$productIds = explode($separator, $items);
foreach ($productIds as $productId) {
// @TODO:- query only once insted of 2
$productFlat = $this->productFlatRepository->findOneWhere(['id' => $productId]);
if ($productFlat) {
$product = $this->productRepository->findOneWhere(['id' => $productFlat->product_id]);
if ($product) {
$formattedProduct = $this->formatProduct($productFlat);
$productMetaDetails = [];
$productMetaDetails['slug'] = $product->url_key;
$productMetaDetails['image'] = $formattedProduct['image'];
$productMetaDetails['priceHTML'] = $formattedProduct['priceHTML'];
$productMetaDetails['addToCartHtml'] = $formattedProduct['addToCartHtml'];
$productMetaDetails['galleryImages'] = $formattedProduct['galleryImages'];
$product = array_merge($productFlat->toArray(), $productMetaDetails);
array_push($productCollection, $product);
}
}
}
return $productCollection;
}
}

View File

@ -24,7 +24,7 @@ class ConfigurationController extends Controller
public function __construct (VelocityMetadataRepository $velocityMetadataRepository)
{
$this->_config = request('_config');
$this->velocityHelper = app('Webkul\Velocity\Helpers\Helper');
$this->velocityMetaDataRepository = $velocityMetadataRepository;
@ -37,7 +37,7 @@ class ConfigurationController extends Controller
{
$velocityMetaData = $this->velocityHelper->getVelocityMetaData();
if ($velocityMetaData->advertisement) {
if ($velocityMetaData && $velocityMetaData->advertisement) {
$velocityMetaData->advertisement = $this->manageAddImages(json_decode($velocityMetaData->advertisement, true));
}
@ -140,9 +140,9 @@ class ConfigurationController extends Controller
if ( isset($advertisement[$index][$imageId]) && $advertisement[$index][$imageId] && !request()->hasFile($file)) {
$saveImage[$imageId] = $advertisement[$index][$imageId];
unset($advertisement[$index][$imageId]);
unset($advertisement[$index][$imageId]);
}
if (request()->hasFile($file) && isset($advertisement[$index][$imageId])) {
Storage::delete($advertisement[$index][$imageId]);

View File

@ -9,38 +9,6 @@ use Webkul\Product\Repositories\ProductRepository;
class CartController extends Controller
{
/**
* Helper object
*
* @var \Webkul\Velocity\Helpers\Helper
*/
protected $velocityHelper;
/**
* ProductRepository object
*
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Velocity\Helpers\Helper $velocityHelper
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
* @return void
*/
public function __construct(
Helper $velocityHelper,
ProductRepository $productRepository
) {
$this->_config = request('_config');
$this->velocityHelper = $velocityHelper;
$this->productRepository = $productRepository;
}
/**
* Retrives the mini cart details
*
@ -102,10 +70,9 @@ class CartController extends Controller
}
if ($cart instanceof CartModel) {
$items = $cart->items;
$formattedItems = [];
foreach ($items as $item) {
foreach ($cart->items as $item) {
array_push($formattedItems, $this->velocityHelper->formatCartItem($item));
}
@ -127,15 +94,15 @@ class CartController extends Controller
$product = $this->productRepository->find($id);
$response = [
'status' => 'danger',
'message' => trans($exception->getMessage()),
'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key),
'status' => 'danger',
'message' => trans($exception->getMessage()),
'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key),
];
}
return $response ?? [
'status' => 'danger',
'message' => trans('velocity::app.error.something_went_wrong'),
'status' => 'danger',
'message' => trans('velocity::app.error.something_went_wrong'),
];
}
@ -151,16 +118,16 @@ class CartController extends Controller
if ($result) {
$response = [
'status' => 'success',
'label' => trans('velocity::app.shop.general.alert.success'),
'message' => trans('shop::app.checkout.cart.item.success-remove'),
'status' => 'success',
'label' => trans('velocity::app.shop.general.alert.success'),
'message' => trans('shop::app.checkout.cart.item.success-remove'),
];
}
return response()->json($response ?? [
'status' => 'danger',
'label' => trans('velocity::app.shop.general.alert.error'),
'message' => trans('velocity::app.error.something_went_wrong'),
'status' => 'danger',
'label' => trans('velocity::app.shop.general.alert.error'),
'message' => trans('velocity::app.error.something_went_wrong'),
], 200);
}
}

View File

@ -4,52 +4,10 @@ namespace Webkul\Velocity\Http\Controllers\Shop;
use Webkul\Velocity\Helpers\Helper;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository;
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository as CustomerCompareProductRepository;
class ComparisonController extends Controller
{
/**
* Helper object
*
* @var \Webkul\Velocity\Helpers\Helper
*/
protected $velocityHelper;
/**
* ProductRepository object
*
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* VelocityCustomerCompareProductRepository object of repository
*
* @var \Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository
*/
protected $velocityCompareProductsRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
* @param \Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository $velocityCompareProductsRepository
* @return void
*/
public function __construct(
Helper $velocityHelper,
ProductRepository $productRepository,
VelocityCustomerCompareProductRepository $velocityCompareProductsRepository
) {
$this->_config = request('_config');
$this->velocityHelper = $velocityHelper;
$this->productRepository = $productRepository;
$this->velocityCompareProductsRepository = $velocityCompareProductsRepository;
}
/**
* function for customers to get products in comparison.
*
@ -62,7 +20,7 @@ class ComparisonController extends Controller
$productCollection = [];
if (auth()->guard('customer')->user()) {
$productCollection = $this->velocityCompareProductsRepository
$productCollection = $this->compareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
@ -83,22 +41,7 @@ class ComparisonController extends Controller
} else {
// for product details
if ($items = request()->get('items')) {
$productSlugs = explode('&', $items);
foreach ($productSlugs as $slug) {
$product = $this->productRepository->findBySlug($slug);
$formattedProduct = $this->velocityHelper->formatProduct($product);
$productMetaDetails = [];
$productMetaDetails['image'] = $formattedProduct['image'];
$productMetaDetails['priceHTML'] = $formattedProduct['priceHTML'];
$productMetaDetails['addToCartHtml'] = $formattedProduct['addToCartHtml'];
$product = array_merge($product->toArray(), $productMetaDetails);
array_push($productCollection, $product);
}
$productCollection = $this->velocityHelper->fetchProductCollection($items);
}
}
@ -124,16 +67,27 @@ class ComparisonController extends Controller
$customerId = auth()->guard('customer')->user()->id;
<<<<<<< HEAD
$compareProduct = $this->velocityCompareProductsRepository->findOneByField([
'customer_id' => $customerId,
=======
$compareProduct = $this->compareProductsRepository->findOneByField([
'customer_id' => $customerId,
>>>>>>> 276a2e288b172d3bacd05662b775a5b320185d51
'product_flat_id' => $productId,
]);
if (! $compareProduct) {
// insert new row
<<<<<<< HEAD
$this->velocityCompareProductsRepository->create([
'customer_id' => $customerId,
'product_flat_id' => $productId,
=======
$this->compareProductsRepository->create([
'customer_id' => $customerId,
'product_flat_id' => $productId,
>>>>>>> 276a2e288b172d3bacd05662b775a5b320185d51
]);
return response()->json([
@ -161,12 +115,12 @@ class ComparisonController extends Controller
if (request()->get('productId') == 'all') {
// delete all
$customerId = auth()->guard('customer')->user()->id;
$this->velocityCompareProductsRepository->deleteWhere([
$this->compareProductsRepository->deleteWhere([
'customer_id' => auth()->guard('customer')->user()->id,
]);
} else {
// delete individual
$this->velocityCompareProductsRepository->deleteWhere([
$this->compareProductsRepository->deleteWhere([
'product_flat_id' => request()->get('productId'),
'customer_id' => auth()->guard('customer')->user()->id,
]);

View File

@ -6,7 +6,115 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Webkul\Velocity\Helpers\Helper;
use Webkul\Product\Helpers\ProductImage;
use Webkul\Product\Repositories\SearchRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRepository;
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository as CustomerCompareProductRepository;
class Controller extends BaseController
{
use DispatchesJobs, ValidatesRequests;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Webkul\Product\Helpers\ProductImage object
*
* @var ProductImage
*/
protected $productImageHelper;
/**
* SearchRepository object
*
* @var SearchRepository
*/
protected $searchRepository;
/**
* ProductRepository object
*
* @var ProductRepository
*/
protected $productRepository;
/**
* ProductRepository object of velocity package
*
* @var ProductRepository
*/
protected $velocityProductRepository;
/**
* CategoryRepository object of velocity package
*
* @var CategoryRepository
*/
protected $categoryRepository;
/**
* WishlistRepository object
*
* @var WishlistRepository
*/
protected $wishlistRepository;
/**
* \Webkul\Velocity\Helpers\Helper object
*
* @var Helper
*/
protected $velocityHelper;
/**
* Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository object of repository
*
* @var VelocityCustomerCompareProductRepository
*/
protected $compareProductsRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Velocity\Helpers\Helper $velocityHelper
* @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 CustomerCompareProductRepository $compareProductsRepository
*
* @return void
*/
public function __construct(
Helper $velocityHelper,
ProductImage $productImageHelper,
SearchRepository $searchRepository,
ProductRepository $productRepository,
WishlistRepository $wishlistRepository,
CategoryRepository $categoryRepository,
VelocityProductRepository $velocityProductRepository,
CustomerCompareProductRepository $compareProductsRepository
) {
$this->_config = request('_config');
$this->velocityHelper = $velocityHelper;
$this->searchRepository = $searchRepository;
$this->productRepository = $productRepository;
$this->productImageHelper = $productImageHelper;
$this->categoryRepository = $categoryRepository;
$this->wishlistRepository = $wishlistRepository;
$this->velocityProductRepository = $velocityProductRepository;
$this->compareProductsRepository = $compareProductsRepository;
}
}

View File

@ -3,90 +3,12 @@
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\Product\ProductRepository as VelocityProductRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Cart;
class ShopController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* ProductImage object
*
* @var \Webkul\Product\Helpers\ProductImage
*/
protected $productImageHelper;
/**
* SearchRepository object
*
* @var \Webkul\Product\Repositories\SearchRepository
*/
protected $searchRepository;
/**
* ProductRepository object
*
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* ProductRepository object of velocity package
*
* @var \Webkul\Velocity\Repositories\Product\ProductRepository
*/
protected $velocityProductRepository;
/**
* CategoryRepository object of velocity package
*
* @var \Webkul\Category\Repositories\CategoryRepository
*/
protected $categoryRepository;
/**
* 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
* @return void
*/
public function __construct(
ProductImage $productImageHelper,
SearchRepository $searchRepository,
ProductRepository $productRepository,
CategoryRepository $categoryRepository,
VelocityProductRepository $velocityProductRepository
) {
$this->_config = request('_config');
$this->searchRepository = $searchRepository;
$this->productRepository = $productRepository;
$this->productImageHelper = $productImageHelper;
$this->categoryRepository = $categoryRepository;
$this->velocityProductRepository = $velocityProductRepository;
}
/**
* Index to handle the view loaded with the search results
*
@ -142,16 +64,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);
} elseif ($slug == "featured-products") {
$products = $productRepository->getFeaturedProducts($count);
$products = $this->velocityProductRepository->getNewProducts($count);
} else if ($slug == "featured-products") {
$products = $this->velocityProductRepository->getFeaturedProducts($count);
}
foreach ($products as $product) {
array_push($formattedProducts, $this->formatProduct($product));
array_push($formattedProducts, $this->velocityHelper->formatProduct($product));
}
$response = [
@ -171,7 +91,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);
}
@ -252,39 +172,61 @@ class ShopController extends Controller
}
/**
* @param \Webkul\Product\Contracts\Product $product
* @param bool $list
* @return array
* @return \Illuminate\View\View
*/
private function formatProduct($product, $list = false)
public function getWishlistList()
{
$reviewHelper = app('Webkul\Product\Helpers\Review');
return view($this->_config['view']);
}
$totalReviews = $reviewHelper->getTotalReviews($product);
/**
* this function will provide the count of wishlist and comparison for logged in user
*
* @return \Illuminate\Http\Response
*/
public function getItemsCount()
{
if ($customer = auth()->guard('customer')->user()) {
$wishlistItemsCount = $this->wishlistRepository->count([
'customer_id' => $customer->id,
'channel_id' => core()->getCurrentChannel()->id,
]);
$avgRatings = ceil($reviewHelper->getAverageRating($product));
$comparedItemsCount = $this->compareProductsRepository->count([
'customer_id' => $customer->id,
]);
$galleryImages = $this->productImageHelper->getGalleryImages($product);
$productImage = $this->productImageHelper->getProductBaseImage($product)['medium_image_url'];
$response = [
'status' => true,
'compareProductsCount' => $comparedItemsCount,
'wishlistedProductsCount' => $wishlistItemsCount,
];
}
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(),
];
return response()->json($response ?? [
'status' => false
]);
}
/**
* This function will provide details of multiple product
*
* @return \Illuminate\Http\Response
*/
public function getDetailedProducts()
{
// for product details
if ($items = request()->get('items')) {
$productCollection = $this->velocityHelper->fetchProductCollection($items);
$response = [
'status' => 'success',
'products' => $productCollection,
];
}
return response()->json($response ?? [
'status' => false
]);
}
}

View File

@ -3,32 +3,53 @@
Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function () {
Route::namespace('Webkul\Velocity\Http\Controllers\Shop')->group(function () {
Route::get('/product-details/{slug}', 'ShopController@fetchProductDetails')
->name('velocity.shop.product');
->name('velocity.shop.product');
Route::get('/categorysearch', 'ShopController@search')->defaults('_config', [
'view' => 'shop::search.search'
])->name('velocity.search.index');
Route::get('/categorysearch', 'ShopController@search')
->name('velocity.search.index')
->defaults('_config', [
'view' => 'shop::search.search'
]);
Route::get('/categories', 'ShopController@fetchCategories')->name('velocity.categoriest');
Route::get('/categories', 'ShopController@fetchCategories')
->name('velocity.categoriest');
Route::get('/category-details', 'ShopController@categoryDetails')->name('velocity.category.details');
Route::get('/category-details', 'ShopController@categoryDetails')
->name('velocity.category.details');
Route::get('/fancy-category-details/{slug}', 'ShopController@fetchFancyCategoryDetails')->name('velocity.fancy.category.details');
Route::get('/mini-cart', 'CartController@getMiniCartDetails')->name('velocity.cart.get.details');
Route::get('/mini-cart', 'CartController@getMiniCartDetails')
->name('velocity.cart.get.details');
Route::post('/cart/add', 'CartController@addProductToCart')->name('velocity.cart.add.product');
Route::post('/cart/add', 'CartController@addProductToCart')
->name('velocity.cart.add.product');
Route::delete('/cart/remove/{id}', 'CartController@removeProductFromCart')->name('velocity.cart.remove.product');
Route::delete('/cart/remove/{id}', 'CartController@removeProductFromCart')
->name('velocity.cart.remove.product');
Route::get('/comparison', 'ComparisonController@getComparisonList')
->name('velocity.product.compare')
->defaults('_config', [
'view' => 'shop::compare.index'
'view' => 'shop::guest.compare.index'
]);
Route::put('/comparison', 'ComparisonController@addCompareProduct')->name('customer.product.add.compare');
Route::put('/comparison', 'ComparisonController@addCompareProduct')
->name('customer.product.add.compare');
Route::delete('/comparison', 'ComparisonController@deleteComparisonProduct')->name('customer.product.delete.compare');
Route::delete('/comparison', 'ComparisonController@deleteComparisonProduct')
->name('customer.product.delete.compare');
Route::get('/guest-wishlist', 'ShopController@getWishlistList')
->name('velocity.product.guest-wishlist')
->defaults('_config', [
'view' => 'shop::guest.wishlist.index'
]);
Route::get('/items-count', 'ShopController@getItemsCount')
->name('velocity.product.details');
Route::get('/detailed-products', 'ShopController@getDetailedProducts')
->name('velocity.product.details');
});
});

View File

@ -56,7 +56,10 @@
<div class="product-price fs16" v-html="product.priceHTML"></div>
<div class="product-rating col-12 no-padding" v-if="product.totalReviews && product.totalReviews > 0">
<div
class="product-rating col-12 no-padding"
v-if="product.totalReviews && product.totalReviews > 0">
<star-ratings :ratings="product.avgRating"></star-ratings>
<a class="fs14 align-top unset active-hover" :href="`${$root.baseUrl}/reviews/${product.slug}`">
{{ __('products.reviews-count', {'totalReviews': product.totalReviews}) }}
@ -67,7 +70,7 @@
<span class="fs14" v-text="product.firstReviewText"></span>
</div>
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
<vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
</div>
</div>
</template>

View File

@ -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`,
@ -58,6 +56,8 @@
);
}
}
this.$root.headerItemsCount++;
}
}
}

View File

@ -43,7 +43,9 @@
<p class="pt14 fs14 description-text" v-html="product.shortDescription"></p>
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
<div class="product-actions">
<vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
</div>
</div>
<div

View File

@ -16,8 +16,8 @@
v-for="(category, categoryIndex) in slicedCategories">
<a
:class="`category unset ${(category.children.length > 0) ? 'fw6' : ''}`"
:href="`${$root.baseUrl}/${category.slug}`">
:href="`${$root.baseUrl}/${category.slug}`"
:class="`category unset ${(category.children.length > 0) ? 'fw6' : ''}`">
<div
class="category-icon"
@ -59,8 +59,10 @@
v-for="(subCategory, subCategoryIndex) in category.children">
<a
:class="`category sub-category unset ${(subCategory.children.length > 0) ? 'fw6' : ''}`"
:href="`${$root.baseUrl}/${category.slug}/${subCategory.slug}`">
:id="`sidebar-level-link-2-${subCategoryIndex}`"
@mouseout="toggleSidebar(id, $event, 'mouseout')"
:href="`${$root.baseUrl}/${category.slug}/${subCategory.slug}`"
:class="`category sub-category unset ${(subCategory.children.length > 0) ? 'fw6' : ''}`">
<div
class="category-icon"
@ -80,6 +82,7 @@
v-for="(childSubCategory, childSubCategoryIndex) in subCategory.children">
<a
:id="`sidebar-level-link-3-${childSubCategoryIndex}`"
:class="`category unset ${(subCategory.children.length > 0) ? 'fw6' : ''}`"
:href="`${$root.baseUrl}/${category.slug}/${subCategory.slug}/${childSubCategory.slug}`">
<span class="category-title">{{ childSubCategory.name }}</span>

View File

@ -10,31 +10,85 @@
<a
v-else
@click="addProductWishlist(productId)"
:href="`${$root.baseUrl}/customer/login`"
@click="toggleProductWishlist(productId)"
:class="`unset wishlist-icon ${addClass ? addClass : ''} text-right`">
<i
:class="`material-icons ${addClass ? addClass : ''}`"
@mouseover="isActive ? isActive = !isActive : ''"
@mouseout="active !== '' && !isActive ? isActive = !isActive : ''">
{{ isActive ? 'favorite_border' : 'favorite' }}
<i
@mouseout="! isStateChanged ? isActive = !isActive : isStateChanged = false"
@mouseover="! isStateChanged ? isActive = !isActive : isStateChanged = false"
:class="`material-icons ${addClass ? addClass : ''}`">
{{ isActive ? 'favorite' : 'favorite_border' }}
</i>
</a>
</template>
<script type="text/javascript">
export default {
props: ['active', 'addClass', 'isCustomer', 'productId'],
props: [
'active',
'addClass',
'addedText',
'productId',
'removeText',
'isCustomer',
'productSlug',
],
data: function () {
return {
isStateChanged: false,
isActive: this.active,
}
},
created: function () {
if (this.isCustomer == 'false') {
this.isActive = this.isWishlisted(this.productId);
}
},
methods: {
addProductWishlist: function () {
toggleProductWishlist: function (productId) {
var updatedValue = [productId];
let existingValue = this.getStorageValue('wishlist_product');
if (existingValue) {
let valueIndex = existingValue.indexOf(productId);
if (valueIndex == -1) {
this.isActive = true;
existingValue.push(productId);
} else {
this.isActive = false;
existingValue.splice(valueIndex, 1);
}
updatedValue = existingValue;
}
this.$root.headerItemsCount++;
this.isStateChanged = true;
this.setStorageValue('wishlist_product', updatedValue);
window.showAlert(
'alert-success',
this.__('shop.general.alert.success'),
this.isActive ? this.addedText : this.removeText
);
return true;
},
isWishlisted: function (productId) {
let existingValue = this.getStorageValue('wishlist_product');
if (existingValue) {
return ! (existingValue.indexOf(productId) == -1);
} else {
return false;
}
}
}
}

View File

@ -59,6 +59,7 @@ $(document).ready(function () {
return {
'baseUrl': document.querySelector("script[src$='velocity.js']").getAttribute('baseUrl'),
'navContainer': false,
'headerItemsCount': 0,
'responsiveSidebarTemplate': '',
'responsiveSidebarKey': Math.random(),
'sharedRootCategories': [],
@ -98,6 +99,7 @@ $(document).ready(function () {
|| Array.from(target.classList)[0] == "rango-arrow-right"
) {
let parentItem = target.closest('li');
if (target.id || parentItem.id.match('category-')) {
let subCategories = $(`#${target.id ? target.id : parentItem.id} .sub-categories`);
@ -184,7 +186,23 @@ $(document).ready(function () {
this.$options.staticRenderFns = _staticRenderFns;
return output;
}
},
getStorageValue: function (key) {
let value = window.localStorage.getItem(key);
if (value) {
value = JSON.parse(value);
}
return value;
},
setStorageValue: function (key, value) {
window.localStorage.setItem(key, JSON.stringify(value));
return true;
},
}
});

View File

@ -514,7 +514,8 @@ header {
// transition: transform .15s,opacity .15s;
}
~ .compare-btn {
~ .compare-btn,
~ .wishlist-btn {
height: 50px;
float: right;
font-size: 18px;
@ -522,8 +523,30 @@ header {
padding: 10px 16px 6px 16px;
i {
margin-right: 5px;
vertical-align: middle;
}
.badge-container {
position: relative;
display: inline-block;
.badge {
@include border-radius(50%);
top: -23px;
left: -15px;
padding: 4px;
min-width: 20px;
position: absolute;
background: $button-primary-bg;
}
}
span {
top: 2px;
position: relative;
}
}
}

View File

@ -276,36 +276,34 @@
}
}
.add-to-cart-btn {
width: 100%;
position: relative;
padding-right: 35px;
.btn-add-to-cart {
max-width: 140px;
&.small-padding {
max-width: 130px;
}
.card-body {
.compare-icon,
.wishlist-icon {
left: 0;
top: 10px;
display: none;
margin-left: 5px;
margin-right: 5px;
position: absolute;
}
~ a {
.compare-icon {
right: 0;
margin: 0;
padding: 0;
height: 38px;
display: table;
cursor: pointer;
text-align: right;
position: absolute;
left: unset;
}
&.compare-icon {
right: 27px;
}
.add-to-cart-btn {
width: 100%;
position: relative;
> i {
display: table-cell;
vertical-align: middle;
.btn-add-to-cart {
width: 100%;
max-width: 140px;
max-width: 100% !important;
&.small-padding {
max-width: 130px;
}
}
}
}
@ -350,7 +348,18 @@
img {
transition: 0.5s all;
transform: scale(1.1);
transform: scale(1.05);
}
}
.compare-icon,
.wishlist-icon {
display: block;
}
.product-price {
.sticker {
display: none;
}
}
}
@ -361,7 +370,7 @@
img {
transition: 0.5s all;
transform: scale(1.1);
transform: scale(1.05);
}
}
}
@ -690,6 +699,11 @@
max-width: 110px;
max-height: 110px;
}
.wishlist-icon {
margin: 0;
display: inline-block;
}
}
.product-details-content {
@ -1228,24 +1242,28 @@
}
}
.alert {
right: 15px !important;
top: 50px !important;
z-index: 100 !important;
font-size: 16px !important;
position: fixed !important;
max-width: 400px !important;
min-height: 45px !important;
max-height: 100px !important;
#alert-container {
top: 50px;
right: 15px;
z-index: 100;
position: fixed;
font-size: 16px;
&.alert-dismissible {
.close {
font-size: 23px;
padding: .3rem 1.25rem;
.alert {
max-width: 400px !important;
min-height: 45px !important;
max-height: 100px !important;
&.alert-dismissible {
.close {
font-size: 23px;
padding: .3rem 1.25rem;
}
}
}
}
.wishlist-icon {
vertical-align: middle;
@ -1524,6 +1542,18 @@
font-weight: 600;
}
.price-from {
span:nth-child(2) {
margin-left: 6px;
text-transform: lowercase;
display: inline-block !important;
}
span:nth-child(3) {
display: block !important;
}
}
.price-label {
margin-right: 6px;
}
@ -1958,6 +1988,7 @@
img {
width: 100%;
height: 100%;
max-height: 500px;
margin-bottom: 30px;
}
}
@ -2180,6 +2211,9 @@
}
.bottom-toolbar {
width: 100%;
display: block;
.pagination {
.page-item {
padding: 0 10px;
@ -2226,14 +2260,6 @@
.VueCarousel-slide {
cursor: default;
}
#new-products-carousel {
.add-to-cart-btn {
~ a {
position: static;
}
}
}
}
.vue-slider {

View File

@ -633,6 +633,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,
@ -640,18 +665,12 @@ body::after {
font-size: 20px;
font-weight: 600;
}
}
.compare-icon,
.wishlist-icon {
height: 38px;
display: table;
cursor: pointer;
margin-left: 10px;
i {
display: table-cell;
vertical-align: middle;
.price-from {
span:nth-child(3) {
margin-left: 6px;
display: inline-block !important;
}
}
}

View File

@ -220,19 +220,37 @@
}
}
.compare-icon,
.wishlist-icon {
height: 46px;
display: table;
cursor: pointer;
padding-left: 10px;
.product-actions {
> div {
display: inline-block;
i {
display: table-cell;
vertical-align: middle;
.add-to-cart-btn {
float: left;
}
.compare-icon,
.wishlist-icon {
height: 46px;
margin-left: 0;
padding-left: 10px;
i {
display: table-cell;
vertical-align: middle;
}
}
.compare-icon {
display: inline-table;
}
.wishlist-icon {
float: right;
}
}
}
.layouter,
#product-form {
height: 100%;

View File

@ -672,22 +672,22 @@ a {
text-decoration: none !important;
}
&.remove-decoration {
text-decoration: none;
}
&.remove-decoration:hover,
&.remove-decoration:active,
&.remove-decoration:focus {
text-decoration: none;
}
&.active-hover {
&:hover {
color: $link-color !important;
text-decoration: underline !important;
}
}
&.remove-decoration {
text-decoration: none !important;
&:hover,
&:active,
&:focus {
text-decoration: none !important;
}
}
}
.dropdown-icon::after {
@ -888,6 +888,7 @@ button[disabled] {
.wishlist-icon {
height: 38px;
display: table;
cursor: pointer;
margin-left: 10px;
i {

View File

@ -56,7 +56,7 @@
<script type="text/x-template" id="searchbar-template">
<div class="row no-margin right searchbar">
<div class="col-lg-8 col-md-12 no-padding input-group">
<div class="col-lg-6 col-md-12 no-padding input-group">
<form
method="GET"
role="search"
@ -114,7 +114,7 @@
</form>
</div>
<div class="col-4">
<div class="col-6">
{!! view_render_event('bagisto.shop.layout.header.cart-item.before') !!}
@include('shop::checkout.cart.mini-cart')
{!! view_render_event('bagisto.shop.layout.header.cart-item.after') !!}
@ -122,9 +122,22 @@
{!! view_render_event('bagisto.shop.layout.header.compare.before') !!}
<a class="compare-btn unset" href="{{ route('velocity.product.compare') }}">
<i class="material-icons">compare_arrows</i>
<span>Compare</span>
<div class="badge-container" v-if="compareCount > 0">
<span class="badge" v-text="compareCount"></span>
</div>
<span>{{ __('velocity::app.customer.compare.text') }}</span>
</a>
{!! view_render_event('bagisto.shop.layout.header.compare.after') !!}
{!! view_render_event('bagisto.shop.layout.header.wishlist.before') !!}
<a class="wishlist-btn unset" :href="`${isCustomer ? '{{ route('customer.wishlist.index') }}' : '{{ route('velocity.product.guest-wishlist') }}'}`">
<i class="material-icons">favorite_border</i>
<div class="badge-container" v-if="wishlistCount > 0">
<span class="badge" v-text="wishlistCount"></span>
</div>
<span>{{ __('shop::app.layouts.wishlist') }}</span>
</a>
{!! view_render_event('bagisto.shop.layout.header.wishlist.after') !!}
</div>
</div>
</script>
@ -524,7 +537,7 @@
event.stopPropagation();
}
}
})
});
Vue.component('close-btn', {
template: '#close-btn-template',
@ -600,7 +613,16 @@
template: '#searchbar-template',
data: function () {
return {
searchedQuery: []
compareCount: 0,
wishlistCount: 0,
searchedQuery: [],
isCustomer: '{{ auth()->guard('customer')->user() ? "true" : "false" }}' == "true",
}
},
watch: {
'$root.headerItemsCount': function () {
this.updateHeaderItemsCount();
}
},
@ -616,14 +638,40 @@
});
this.searchedQuery = updatedSearchedCollection;
this.updateHeaderItemsCount();
},
methods: {
'focusInput': function (event) {
$(event.target.parentElement.parentElement).find('input').focus();
},
'updateHeaderItemsCount': function () {
if (! this.isCustomer) {
let comparedItems = this.getStorageValue('compared_product');
let wishlistedItems = this.getStorageValue('wishlist_product');
if (wishlistedItems) {
this.wishlistCount = wishlistedItems.length;
}
if (comparedItems) {
this.compareCount = comparedItems.length;
}
} else {
this.$http.get(`${this.$root.baseUrl}/items-count`)
.then(response => {
this.compareCount = response.data.compareProductsCount;
this.wishlistCount = response.data.wishlistedProductsCount;
})
.catch(exception => {
console.log(this.__('error.something_went_wrong'));
});
}
}
}
})
});
Vue.component('content-header', {
template: '#content-header-template',
@ -697,6 +745,6 @@
this[metaKey] = !this[metaKey];
}
},
})
});
})()
</script>

View File

@ -35,6 +35,7 @@
@include ('shop::products.list.card', [
'checkmode' => true,
'itemId' => $item->id,
'addToCartForm' => true,
'removeWishlist' => true,
'product' => $item->product,
'btnText' => $moveToCartText,

View File

@ -21,7 +21,11 @@
</h1>
<div class="col-6" v-if="products.length > 0">
<button class="theme-btn light pull-right" @click="removeProductCompare('all')">Clear All</button>
<button
class="theme-btn light pull-right"
@click="removeProductCompare('all')">
{{ __('shop::app.customer.account.wishlist.deleteall') }}
</button>
</div>
{!! view_render_event('bagisto.shop.customers.account.compare.view.before') !!}
@ -49,36 +53,53 @@
</div>
<div class="col" :key="`title-${index}`" v-for="(product, index) in products">
@if ($attribute['code'] == 'name')
<a :href="`${$root.baseUrl}/${product.url_key}`" class="unset">
<h1 class="fw6 fs18" v-text="product['{{ $attribute['code'] }}']"></h1>
</a>
@elseif ($attribute['code'] == 'image')
<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')
<div class="action">
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
@switch ($attribute['code'])
@case('name')
<a :href="`${$root.baseUrl}/${product.url_key}`" class="unset remove-decoration active-hover">
<h1 class="fw6 fs18" v-text="product['{{ $attribute['code'] }}']"></h1>
</a>
@break
<i
class="material-icons cross fs16"
@click="removeProductCompare(isCustomer ? product.id : product.slug)">
@case('image')
<a :href="`${$root.baseUrl}/${product.url_key}`" class="unset">
<img :src="product['{{ $attribute['code'] }}']" class="image-wrapper"></span>
</a>
@break
close
</i>
</div>
@elseif ($attribute['code'] == 'color')
<span v-html="product.color_label"></span>
@elseif ($attribute['code'] == 'size')
<span v-html="product.size_label"></span>
@elseif ($attribute['code'] == 'size')
<span v-html="product.size_label"></span>
@else
<span v-html="product['{{ $attribute['code'] }}']"></span>
@endif
@case('price')
<span v-html="product['priceHTML']"></span>
@break
@case('addToCartHtml')
<div class="action">
<vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
<i
class="material-icons cross fs16"
@click="removeProductCompare(product.id)">
close
</i>
</div>
@break
@case('color')
<span v-html="product.color_label" class="fs16"></span>
@break
@case('size')
<span v-html="product.size_label" class="fs16"></span>
@break
@case('description')
<span v-html="product.description"></span>
@break
@default
<span v-html="product['{{ $attribute['code'] }}']" class="fs16"></span>
@break
@endswitch
</div>
</div>
@endforeach
@ -111,32 +132,37 @@
methods: {
'getComparedProducts': function () {
if (this.isCustomer) {
var data = {
params: {
data: true,
}
};
} else {
let items = JSON.parse(window.localStorage.getItem('compared_product'));
let items = '';
let url = `${this.$root.baseUrl}/${this.isCustomer ? 'comparison' : 'detailed-products'}`;
let data = {
params: {'data': true}
}
if (! this.isCustomer) {
items = this.getStorageValue('compared_product');
items = items ? items.join('&') : '';
var data = {
data = {
params: {
items,
data: true,
items
}
};
}
this.$http.get(`${this.$root.baseUrl}/comparison`, 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) {
@ -155,18 +181,17 @@
console.log(this.__('error.something_went_wrong'));
});
} else {
let existingItems = window.localStorage.getItem('compared_product');
existingItems = JSON.parse(existingItems);
let existingItems = this.getStorageValue('compared_product');
if (productId == "all") {
updatedItems = [];
this.$set(this, 'products', []);
} else {
updatedItems = existingItems.filter(item => item != productId);
this.$set(this, 'products', this.products.filter(product => product.slug != productId));
this.$set(this, 'products', this.products.filter(product => product.id != productId));
}
window.localStorage.setItem('compared_product', JSON.stringify(updatedItems));
this.setStorageValue('compared_product', updatedItems);
window.showAlert(
`alert-success`,
@ -174,6 +199,8 @@
`${this.__('customer.compare.removed')}`
);
}
this.$root.headerItemsCount++;
},
}
});

View File

@ -0,0 +1,128 @@
@extends('shop::layouts.master')
@section('page_title')
{{ __('shop::app.customer.account.wishlist.page-title') }}
@endsection
@section('content-wrapper')
@guest('customer')
<wishlist-product></wishlist-product>
@endguest
@auth('customer')
@push('scripts')
<script>
window.location = '{{ route('customer.wishlist.index') }}';
</script>
@endpush
@endauth
@endsection
@push('scripts')
<script type="text/x-template" id="wishlist-product-template">
<section class="cart-details row no-margin col-12">
<h1 class="fw6 col-6">
{{ __('shop::app.customer.account.wishlist.title') }}
</h1>
<div class="col-6" v-if="products.length > 0">
<button
class="theme-btn light pull-right"
@click="removeProduct('all')">
{{ __('shop::app.customer.account.wishlist.deleteall') }}
</button>
</div>
{!! view_render_event('bagisto.shop.customers.account.guest-customer.view.before') !!}
<div class="row products-collection col-12 ml0">
<template v-if="products.length > 0">
<carousel-component
slides-per-page="6"
navigation-enabled="hide"
pagination-enabled="hide"
id="wishlist-products-carousel"
:slides-count="products.length">
<slide
:key="index"
:slot="`slide-${index}`"
v-for="(product, index) in products">
<product-card :product="product"></product-card>
</slide>
</carousel-component>
</template>
<span v-else>{{ __('customer::app.wishlist.empty') }}</span>
</div>
{!! view_render_event('bagisto.shop.customers.account.guest-customer.view.after') !!}
</section>
</script>
<script>
Vue.component('wishlist-product', {
template: '#wishlist-product-template',
data: function () {
return {
'products': [],
'isProductListLoaded': false,
}
},
watch: {
'$root.headerItemsCount': function () {
this.getProducts();
}
},
mounted: function () {
this.getProducts();
},
methods: {
'getProducts': function () {
let items = this.getStorageValue('wishlist_product');
items = items ? items.join('&') : '';
if (items != "") {
this.$http
.get(`${this.$root.baseUrl}/detailed-products`, {
params: { items }
})
.then(response => {
this.isProductListLoaded = true;
this.products = response.data.products;
})
.catch(error => {
console.log(this.__('error.something_went_wrong'));
});
}
},
'removeProduct': function (productId) {
let existingItems = this.getStorageValue('wishlist_product');
if (productId == "all") {
updatedItems = [];
this.$set(this, 'products', []);
} else {
updatedItems = existingItems.filter(item => item != productId);
this.$set(this, 'products', this.products.filter(product => product.slug != productId));
}
this.$root.headerItemsCount++;
this.setStorageValue('wishlist_product', updatedItems);
window.showAlert(
`alert-success`,
this.__('shop.general.alert.success'),
`${this.__('customer.compare.removed')}`
);
}
}
});
</script>
@endpush

View File

@ -6,9 +6,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="content-language" content="{{ app()->getLocale() }}">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="{{ asset('themes/velocity/assets/css/velocity.css') }}" />
<link rel="stylesheet" href="{{ asset('themes/velocity/assets/css/bootstrap.min.css') }}" />
@ -130,20 +130,24 @@
{!! view_render_event('bagisto.shop.layout.body.after') !!}
<div id="alert-container"></div>
<script type="text/javascript">
(() => {
window.showAlert = (messageType, messageLabel, message) => {
if (messageType && message !== '') {
let html = `<div class="alert ${messageType} alert-dismissible" id="alert">
let alertId = Math.floor(Math.random() * 1000);
let html = `<div class="alert ${messageType} alert-dismissible" id="${alertId}">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>${messageLabel ? messageLabel + '!' : ''} </strong> ${message}.
</div>`;
$('body').append(html);
window.setTimeout(() => {
$(".alert").remove();
}, 5000);
$('#alert-container').append(html).ready(() => {
window.setTimeout(() => {
$(`#alert-container #${alertId}`).remove();
}, 5000);
});
}
}
@ -185,6 +189,5 @@
</script>
@stack('scripts')
</body>
</html>

View File

@ -1,34 +1,6 @@
{!! view_render_event('bagisto.shop.products.add_to_cart.before', ['product' => $product]) !!}
<div class="row mx-0 col-12 no-padding">
<div class="add-to-cart-btn pl0">
@if (isset($form) && !$form)
<button
type="submit"
{{ ! $product->isSaleable() ? 'disabled' : '' }}
class="btn btn-add-to-cart {{ $addToCartBtnClass ?? '' }}">
@if (! (isset($showCartIcon) && !$showCartIcon))
<i class="material-icons text-down-3">shopping_cart</i>
@endif
<span class="fs14 fw6 text-uppercase text-up-4">
{{ __('shop::app.products.add-to-cart') }}
</span>
</button>
@else
<add-to-cart
form="true"
csrf-token='{{ csrf_token() }}'
product-id="{{ $product->product_id }}"
add-class-to-btn="{{ $addToCartBtnClass ?? '' }}"
is-enable={{ ! $product->isSaleable() ? 'false' : 'true' }}
show-cart-icon={{ !(isset($showCartIcon) && !$showCartIcon) }}
btn-text="{{ $btnText ?? __('shop::app.products.add-to-cart') }}">
</add-to-cart>
@endif
</div>
<div class="mx-0 no-padding">
@if (isset($showCompare) && $showCompare)
<compare-component
@auth('customer')
@ -49,6 +21,57 @@
'addClass' => $addWishlistClass ?? ''
])
@endif
<div class="add-to-cart-btn pl0">
@if (isset($form) && !$form)
<button
type="submit"
{{ ! $product->isSaleable() ? 'disabled' : '' }}
class="btn btn-add-to-cart {{ $addToCartBtnClass ?? '' }}">
@if (! (isset($showCartIcon) && !$showCartIcon))
<i class="material-icons text-down-3">shopping_cart</i>
@endif
<span class="fs14 fw6 text-uppercase text-up-4">
{{ __('shop::app.products.add-to-cart') }}
</span>
</button>
@elseif(isset($addToCartForm) && !$addToCartForm)
<form
method="POST"
action="{{ route('cart.add', $product->product_id) }}">
@csrf
<input type="hidden" name="product_id" value="{{ $product->product_id }}">
<input type="hidden" name="quantity" value="1">
<button
type="submit"
{{ ! $product->isSaleable() ? 'disabled' : '' }}
class="btn btn-add-to-cart {{ $addToCartBtnClass ?? '' }}">
@if (! (isset($showCartIcon) && !$showCartIcon))
<i class="material-icons text-down-3">shopping_cart</i>
@endif
<span class="fs14 fw6 text-uppercase text-up-4">
{{ $btnText ?? __('shop::app.products.add-to-cart') }}
</span>
</button>
</form>
@else
<add-to-cart
form="true"
csrf-token='{{ csrf_token() }}'
product-id="{{ $product->product_id }}"
add-class-to-btn="{{ $addToCartBtnClass ?? '' }}"
is-enable={{ ! $product->isSaleable() ? 'false' : 'true' }}
show-cart-icon={{ !(isset($showCartIcon) && !$showCartIcon) }}
btn-text="{{ $btnText ?? __('shop::app.products.add-to-cart') }}">
</add-to-cart>
@endif
</div>
</div>
{!! view_render_event('bagisto.shop.products.add_to_cart.after', ['product' => $product]) !!}

View File

@ -117,13 +117,13 @@
</div>
@endif
<div class="cart-wish-wrap row col-12 no-padding ml0">
<div class="cart-wish-wrap no-padding ml0">
@include ('shop::products.add-to-cart', [
'product' => $product,
'addWishlistClass' => 'col-lg-4 col-md-4 col-sm-12 offset-lg-4 pr0',
'showCompare' => true,
'showCompare' => true,
'product' => $product,
'btnText' => $btnText ?? null,
'addToCartForm' => $addToCartForm ?? false,
'addToCartBtnClass' => $addToCartBtnClass ?? '',
'btnText' => $btnText ?? null
])
</div>
</div>

View File

@ -94,12 +94,14 @@
@include ('shop::products.price', ['product' => $product])
</div>
@include ('shop::products.add-to-cart', [
'form' => false,
'product' => $product,
'showCompare' => true,
'showCartIcon' => false,
])
<div class="product-actions">
@include ('shop::products.add-to-cart', [
'form' => false,
'product' => $product,
'showCompare' => true,
'showCartIcon' => false,
])
</div>
</div>
{!! view_render_event('bagisto.shop.products.view.short_description.before', ['product' => $product]) !!}

View File

@ -5,7 +5,7 @@
$customAttributeValues = $productViewHelper->getAdditionalData($product);
@endphp
@if ($customAttributeValues && $customAttributeValues[0]['value'])
@if ($customAttributeValues)
<accordian :title="'{{ __('shop::app.products.specification') }}'" :active="'{{ $active }}' == true ? true : false">
<div slot="header">
<h3 class="no-margin display-inbl">

View File

@ -24,8 +24,11 @@
<wishlist-component
active="false"
is-customer="false"
product-id="{{ $product->product_id }}"
add-class="{{ $addWishlistClass ?? '' }}">
product-id="{{ $product->id }}"
product-slug="{{ $product->url_key }}"
add-class="{{ $addWishlistClass ?? '' }}"
added-text="{{ __('shop::app.customer.account.wishlist.add') }}"
remove-text="{{ __('shop::app.customer.account.wishlist.remove') }}">
</wishlist-component>
@endauth
{!! view_render_event('bagisto.shop.products.wishlist.after') !!}