ajaxified add to cart, modified controllers
This commit is contained in:
parent
8b2c955dd3
commit
8a1ab165da
|
|
@ -112,8 +112,9 @@ class CartController extends Controller
|
|||
{
|
||||
$result = Cart::removeItem($itemId);
|
||||
|
||||
if ($result)
|
||||
if ($result) {
|
||||
session()->flash('success', trans('shop::app.checkout.cart.item.success-remove'));
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"/js/velocity.js": "/js/velocity.js?id=f020eef94ee576cd6b41",
|
||||
"/js/velocity.js": "/js/velocity.js?id=e684d1525630d617481b",
|
||||
"/css/velocity-admin.css": "/css/velocity-admin.css?id=612d35e452446366eef7",
|
||||
"/css/velocity.css": "/css/velocity.css?id=0c3bbabfcb61f4640459"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,9 +138,9 @@ class Helper extends Review
|
|||
/**
|
||||
* Returns the count rating of the product
|
||||
*
|
||||
* @param Product $product
|
||||
* @param Product $product
|
||||
* @return array
|
||||
*/
|
||||
*/
|
||||
public function getCountRating($product)
|
||||
{
|
||||
$reviews = $product->reviews()->where('status', 'approved')
|
||||
|
|
@ -221,5 +221,37 @@ class Helper extends Review
|
|||
'baseTotal' => core()->currency($item->base_total),
|
||||
];
|
||||
}
|
||||
|
||||
public 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'];
|
||||
|
||||
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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Velocity\Http\Controllers\Shop;
|
||||
|
||||
use Cart;
|
||||
use Webkul\Velocity\Helpers\Helper;
|
||||
use Webkul\Checkout\Contracts\Cart as CartModel;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
/**
|
||||
* Cart controller
|
||||
*
|
||||
* @author Shubham Mehrotra <shubhammehrotra.symfony@webkul.com> @shubhwebkul
|
||||
* @copyright 2020 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class CartController extends Controller
|
||||
{
|
||||
/**
|
||||
* Webkul\Velocity\Helpers\Helper object
|
||||
*
|
||||
* @var Helper
|
||||
*/
|
||||
protected $velocityHelper;
|
||||
|
||||
/**
|
||||
* Webkul\Product\Repositories\ProductRepository object
|
||||
*
|
||||
* @var ProductRepository
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Helper $velocityHelper,
|
||||
ProductRepository $productRepository
|
||||
) {
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->velocityHelper = $velocityHelper;
|
||||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrives the mini cart details
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getMiniCartDetails()
|
||||
{
|
||||
$cart = cart()->getCart();
|
||||
|
||||
if ($cart) {
|
||||
$items = $cart->items;
|
||||
$cartItems = $items->toArray();
|
||||
|
||||
$cartDetails = [];
|
||||
$cartDetails['base_sub_total'] = core()->currency($cart->base_sub_total);
|
||||
|
||||
foreach ($items as $index => $item) {
|
||||
$images = $item->product->getTypeInstance()->getBaseImage($item);
|
||||
|
||||
$cartItems[$index]['images'] = $images;
|
||||
$cartItems[$index]['url_key'] = $item->product->url_key;
|
||||
$cartItems[$index]['base_total'] = core()->currency($item->base_total);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'mini_cart' => [
|
||||
'cart_items' => $cartItems,
|
||||
'cart_details' => $cartDetails,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
'status' => false,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for guests user to add the product in the cart.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function addProductToCart()
|
||||
{
|
||||
try {
|
||||
$cart = Cart::getCart();
|
||||
$id = request()->get('product_id');
|
||||
|
||||
$cart = Cart::addProduct($id, request()->all());
|
||||
|
||||
if (is_array($cart) && isset($cart['warning'])) {
|
||||
$response = [
|
||||
'status' => 'warning',
|
||||
'message' => $cart['warning'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($cart instanceof CartModel) {
|
||||
$items = $cart->items;
|
||||
$formattedItems = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
array_push($formattedItems, $this->velocityHelper->formatCartItem($item));
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => 'success',
|
||||
'totalCartItems' => sizeof($items),
|
||||
'message' => trans('shop::app.checkout.cart.item.success'),
|
||||
];
|
||||
|
||||
if ($customer = auth()->guard('customer')->user()) {
|
||||
app('Webkul\Customer\Repositories\WishlistRepository')->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]);
|
||||
}
|
||||
|
||||
if (request()->get('is_buy_now')) {
|
||||
return redirect()->route('shop.checkout.onepage.index');
|
||||
}
|
||||
}
|
||||
} catch(\Exception $exception) {
|
||||
$product = $this->productRepository->find($id);
|
||||
|
||||
$response = [
|
||||
'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'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the item from the cart if it exists
|
||||
*
|
||||
* @param integer $itemId
|
||||
* @return Response
|
||||
*/
|
||||
public function removeProductFromCart($itemId)
|
||||
{
|
||||
$result = Cart::removeItem($itemId);
|
||||
|
||||
if ($result) {
|
||||
$response = [
|
||||
'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'),
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Velocity\Http\Controllers\Shop;
|
||||
|
||||
use Webkul\Velocity\Helpers\Helper;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository;
|
||||
|
||||
/**
|
||||
* Comparison controller
|
||||
*
|
||||
* @author Shubham Mehrotra <shubhammehrotra.symfony@webkul.com> @shubhwebkul
|
||||
* @copyright 2020 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class ComparisonController extends Controller
|
||||
{
|
||||
/**
|
||||
* Webkul\Velocity\Helpers\Helper object
|
||||
*
|
||||
* @var Helper
|
||||
*/
|
||||
protected $velocityHelper;
|
||||
|
||||
/**
|
||||
* Webkul\Product\Repositories\ProductRepository object
|
||||
*
|
||||
* @var ProductRepository
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository object of repository
|
||||
*
|
||||
* @var 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.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function getComparisonList()
|
||||
{
|
||||
if (request()->get('data')) {
|
||||
$productSlugs = null;
|
||||
$productCollection = [];
|
||||
|
||||
if (auth()->guard('customer')->user()) {
|
||||
$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();
|
||||
|
||||
foreach ($productCollection as $index => $customerCompare) {
|
||||
$product = $this->productRepository->find($customerCompare['product_id']);
|
||||
$formattedProduct = $this->velocityHelper->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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => 'success',
|
||||
'products' => $productCollection,
|
||||
];
|
||||
} else {
|
||||
$response = view($this->_config['view']);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* function for customers to add product in comparison.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function addCompareProduct()
|
||||
{
|
||||
$productId = request()->get('productId');
|
||||
$customerId = auth()->guard('customer')->user()->id;
|
||||
|
||||
$compareProduct = $this->velocityCompareProductsRepository->findOneByField([
|
||||
'customer_id' => $customerId,
|
||||
'product_flat_id' => $productId,
|
||||
]);
|
||||
|
||||
if (! $compareProduct) {
|
||||
// insert new row
|
||||
$this->velocityCompareProductsRepository->create([
|
||||
'customer_id' => $customerId,
|
||||
'product_flat_id' => $productId,
|
||||
]);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function for customers to delete product in comparison.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function deleteComparisonProduct()
|
||||
{
|
||||
// either delete all or individual
|
||||
if (request()->get('productId') == 'all') {
|
||||
// delete all
|
||||
$customerId = auth()->guard('customer')->user()->id;
|
||||
$this->velocityCompareProductsRepository->deleteWhere([
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
]);
|
||||
} else {
|
||||
// delete individual
|
||||
$this->velocityCompareProductsRepository->deleteWhere([
|
||||
'product_flat_id' => request()->get('productId'),
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => trans('velocity::app.customer.compare.removed'),
|
||||
'label' => trans('velocity::app.shop.general.alert.success'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ use Webkul\Checkout\Contracts\Cart as CartModel;
|
|||
use Webkul\Product\Repositories\SearchRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
use Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository;
|
||||
use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRepository;
|
||||
|
||||
/**
|
||||
|
|
@ -20,7 +19,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
* @author Shubham Mehrotra <shubhammehrotra.symfony@webkul.com> @shubhwebkul
|
||||
* @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class ShopController extends Controller
|
||||
class ShopController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contains route related configuration
|
||||
|
|
@ -47,7 +46,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
* ProductRepository object
|
||||
*
|
||||
* @var ProductRepository
|
||||
*/
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
|
|
@ -64,13 +63,6 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
*/
|
||||
protected $categoryRepository;
|
||||
|
||||
/**
|
||||
* VelocityCustomerCompareProductRepository object of velocity package
|
||||
*
|
||||
* @var VelocityCustomerCompareProductRepository
|
||||
*/
|
||||
protected $velocityCompareProductsRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
|
|
@ -79,7 +71,6 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
|
||||
* @param \Webkul\Velocity\Repositories\Product\ProductRepository $velocityProductRepository
|
||||
* @param \Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository $velocityCompareProductsRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -87,8 +78,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
SearchRepository $searchRepository,
|
||||
ProductRepository $productRepository,
|
||||
CategoryRepository $categoryRepository,
|
||||
VelocityProductRepository $velocityProductRepository,
|
||||
VelocityCustomerCompareProductRepository $velocityCompareProductsRepository
|
||||
VelocityProductRepository $velocityProductRepository
|
||||
) {
|
||||
$this->_config = request('_config');
|
||||
|
||||
|
|
@ -97,7 +87,6 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
$this->productImageHelper = $productImageHelper;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
$this->velocityProductRepository = $velocityProductRepository;
|
||||
$this->velocityCompareProductsRepository = $velocityCompareProductsRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -278,213 +267,4 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep
|
|||
])->render(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for guests user to add the product in the cart.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function addProductToCart()
|
||||
{
|
||||
try {
|
||||
$cart = Cart::getCart();
|
||||
$formattedBeforeItems = [];
|
||||
$id = request()->get('product_id');
|
||||
$velocityHelper = app('Webkul\Velocity\Helpers\Helper');
|
||||
|
||||
if ($cart) {
|
||||
$beforeItems = $cart->items;
|
||||
|
||||
foreach ($beforeItems as $item) {
|
||||
array_push($formattedBeforeItems, $velocityHelper->formatCartItem($item));
|
||||
}
|
||||
}
|
||||
|
||||
$cart = Cart::addProduct($id, request()->all());
|
||||
|
||||
if (is_array($cart) && isset($cart['warning'])) {
|
||||
$response = [
|
||||
'status' => 'warning',
|
||||
'message' => $cart['warning'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($cart instanceof CartModel) {
|
||||
$items = $cart->items;
|
||||
$formattedItems = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
array_push($formattedItems, $velocityHelper->formatCartItem($item));
|
||||
}
|
||||
|
||||
$response = [
|
||||
'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()) {
|
||||
$this->wishlistRepository->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]);
|
||||
}
|
||||
|
||||
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),
|
||||
];
|
||||
}
|
||||
|
||||
return $response ?? [
|
||||
'status' => 'error',
|
||||
'message' => trans('velocity::app.error.something-went-wrong'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* function for customers to get products in comparison.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function getComparisonList(Request $request)
|
||||
{
|
||||
if (request()->get('data')) {
|
||||
$productSlugs = null;
|
||||
$productCollection = [];
|
||||
|
||||
if (auth()->guard('customer')->user()) {
|
||||
$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();
|
||||
|
||||
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);
|
||||
|
||||
foreach ($productSlugs as $slug) {
|
||||
$product = $this->productRepository->findBySlug($slug);
|
||||
|
||||
$formattedProduct = $this->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => 'success',
|
||||
'products' => $productCollection,
|
||||
];
|
||||
} else {
|
||||
$response = view($this->_config['view']);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* function for customers to add product in comparison.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function addCompareProduct()
|
||||
{
|
||||
$productId = request()->get('productId');
|
||||
$customerId = auth()->guard('customer')->user()->id;
|
||||
|
||||
$compareProduct = $this->velocityCompareProductsRepository->findOneByField([
|
||||
'customer_id' => $customerId,
|
||||
'product_flat_id' => $productId,
|
||||
]);
|
||||
|
||||
if (! $compareProduct) {
|
||||
// insert new row
|
||||
$this->velocityCompareProductsRepository->create([
|
||||
'customer_id' => $customerId,
|
||||
'product_flat_id' => $productId,
|
||||
]);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function for customers to delete product in comparison.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function deleteComparisonProduct()
|
||||
{
|
||||
// either delete all or individual
|
||||
if (request()->get('productId') == 'all') {
|
||||
// delete all
|
||||
$customerId = auth()->guard('customer')->user()->id;
|
||||
$this->velocityCompareProductsRepository->deleteWhere([
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
]);
|
||||
} else {
|
||||
// delete individual
|
||||
$this->velocityCompareProductsRepository->deleteWhere([
|
||||
'product_flat_id' => request()->get('productId'),
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
]);
|
||||
|
||||
// $comparedList = json_decode($customer->compared_product, true);
|
||||
|
||||
// $index = array_search($productId, $comparedList);
|
||||
|
||||
// if ($index > -1) {
|
||||
// unset($comparedList[$index]);
|
||||
|
||||
// $this->velocityCustomerDataRepository->update([
|
||||
// 'compared_product' => json_encode($comparedList),
|
||||
// ], $customer->id);
|
||||
// }
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => trans('velocity::app.customer.compare.removed'),
|
||||
'label' => trans('velocity::app.shop.general.alert.success'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,20 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
|
||||
Route::get('/fancy-category-details/{slug}', 'ShopController@fetchFancyCategoryDetails')->name('velocity.fancy.category.details');
|
||||
|
||||
Route::post('/cart/add', 'ShopController@addProductToCart')->name('velocity.cart.add.product');
|
||||
Route::get('/mini-cart', 'CartController@getMiniCartDetails')->name('velocity.cart.get.details');
|
||||
|
||||
Route::get('/comparison', 'ShopController@getComparisonList')
|
||||
Route::post('/cart/add', 'CartController@addProductToCart')->name('velocity.cart.add.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'
|
||||
]);
|
||||
|
||||
Route::put('/comparison', 'ShopController@addCompareProduct')->name('customer.product.add.compare');
|
||||
Route::put('/comparison', 'ComparisonController@addCompareProduct')->name('customer.product.add.compare');
|
||||
|
||||
Route::delete('/comparison', 'ShopController@deleteComparisonProduct')->name('customer.product.delete.compare');
|
||||
Route::delete('/comparison', 'ComparisonController@deleteComparisonProduct')->name('customer.product.delete.compare');
|
||||
});
|
||||
});
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<form method="POST" @submit.prevent="addToCart">
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isButtonEnable == 'false'"
|
||||
:disabled="isButtonEnable == 'false' || isButtonEnable == false"
|
||||
:class="`btn btn-add-to-cart ${addClassToBtn}`">
|
||||
|
||||
<i class="material-icons text-down-3" v-if="showCartIcon">shopping_cart</i>
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
data: function () {
|
||||
return {
|
||||
'qtyText': this.__('checkout.qty'),
|
||||
'isButtonEnable': this.isEnable,
|
||||
'qtyText': this.__('checkout.qty'),
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -44,45 +44,20 @@
|
|||
.then(response => {
|
||||
this.isButtonEnable = true;
|
||||
|
||||
if (response.data.status) {
|
||||
response.data.addedItems.forEach(item => {
|
||||
let cartItemHTML = `<div class="row small-card-container">
|
||||
<div class="col-3 product-image-container mr15">
|
||||
<a href="${this.$root.baseUrl}/checkout/cart/remove/${item.itemId}">
|
||||
<span class="rango-close"></span>
|
||||
</a>
|
||||
if (response.data.status == 'success') {
|
||||
this.$root.miniCartKey++;
|
||||
|
||||
<a
|
||||
href="${this.$root.baseUrl}/${item.url_key}"
|
||||
class="unset">
|
||||
window.showAlert(`alert-success`, this.__('shop.general.alert.success'), response.data.message);
|
||||
} else {
|
||||
window.showAlert(`alert-${response.data.status}`, response.data.label ? response.data.label : this.__('shop.general.alert.error'), response.data.message);
|
||||
|
||||
<div class="product-image"
|
||||
style="background-image: url('${item.images['small_image_url']}');">
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-9 no-padding card-body align-vertical-top">
|
||||
<div class="no-padding">
|
||||
<div class="fs16 text-nowrap fw6">${item.name}</div>
|
||||
<div class="fs18 card-current-price fw6">
|
||||
<div class="display-inbl">
|
||||
<label class="fw5">${this.qtyText}</label>
|
||||
|
||||
<input type="text" disabled value="${item.quantity}" class="ml5" />
|
||||
</div>
|
||||
<span class="card-total-price fw6">${item.baseTotal}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$('#cart-modal-content .mini-cart-container').append(cartItemHTML);
|
||||
$('.mini-cart-container .badge').text(response.data.totalCartItems);
|
||||
});
|
||||
if (response.data.redirectionRoute) {
|
||||
window.location.href = response.data.redirectionRoute;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,64 +1,66 @@
|
|||
<template>
|
||||
<div
|
||||
id="cart-modal-content"
|
||||
class="modal-content sensitive-modal cart-modal-content hide">
|
||||
<div :class="`dropdown ${cartItems.length > 0 ? '' : 'disable-active'}`">
|
||||
<cart-btn :item-count="cartItems.length"></cart-btn>
|
||||
|
||||
<!--Body-->
|
||||
<div class="mini-cart-container">
|
||||
<div class="row small-card-container" :key="index" v-for="(item, index) in cartItems">
|
||||
<div class="col-3 product-image-container mr15">
|
||||
<a :href="removeUrl">
|
||||
<span class="rango-close"></span>
|
||||
</a>
|
||||
<div
|
||||
id="cart-modal-content"
|
||||
v-if="cartItems.length > 0"
|
||||
class="modal-content sensitive-modal cart-modal-content hide">
|
||||
|
||||
<a
|
||||
class="unset"
|
||||
:href="`${$root.baseUrl}/${item.url_key}`">
|
||||
<!--Body-->
|
||||
<div class="mini-cart-container">
|
||||
<div class="row small-card-container" :key="index" v-for="(item, index) in cartItems">
|
||||
<div class="col-3 product-image-container mr15">
|
||||
<a @click="removeProduct(item.id)">
|
||||
<span class="rango-close"></span>
|
||||
</a>
|
||||
|
||||
<div
|
||||
class="product-image"
|
||||
:style="`background-image: url(${item.images.medium_image_url});`">
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-9 no-padding card-body align-vertical-top">
|
||||
<div class="no-padding">
|
||||
<div class="fs16 text-nowrap fw6" v-html="item.name"></div>
|
||||
|
||||
<div class="fs18 card-current-price fw6">
|
||||
<div class="display-inbl">
|
||||
<label class="fw5">{{ __('checkout.qty') }}</label>
|
||||
<input type="text" disabled :value="item.quantity" class="ml5" />
|
||||
<a class="unset" :href="`${$root.baseUrl}/${item.url_key}`">
|
||||
<div
|
||||
class="product-image"
|
||||
:style="`background-image: url(${item.images.medium_image_url});`">
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-9 no-padding card-body align-vertical-top">
|
||||
<div class="no-padding">
|
||||
<div class="fs16 text-nowrap fw6" v-html="item.name"></div>
|
||||
|
||||
<div class="fs18 card-current-price fw6">
|
||||
<div class="display-inbl">
|
||||
<label class="fw5">{{ __('checkout.qty') }}</label>
|
||||
<input type="text" disabled :value="item.quantity" class="ml5" />
|
||||
</div>
|
||||
<span class="card-total-price fw6">
|
||||
{{ item.base_total }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="card-total-price fw6">
|
||||
{{ item.base_total }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Footer-->
|
||||
<div class="modal-footer">
|
||||
<h2 class="col-6 text-left fw6">
|
||||
{{ subtotalText }}
|
||||
</h2>
|
||||
<!--Footer-->
|
||||
<div class="modal-footer">
|
||||
<h2 class="col-6 text-left fw6">
|
||||
{{ subtotalText }}
|
||||
</h2>
|
||||
|
||||
<h2 class="col-6 text-right fw6 no-padding">{{ cartInformation.base_sub_total }}</h2>
|
||||
</div>
|
||||
<h2 class="col-6 text-right fw6 no-padding">{{ cartInformation.base_sub_total }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<a class="col text-left fs16 link-color remove-decoration" :href="checkoutUrl">{{ cartText }}</a>
|
||||
<div class="modal-footer">
|
||||
<a class="col text-left fs16 link-color remove-decoration" :href="viewCart">{{ cartText }}</a>
|
||||
|
||||
<div class="col text-right no-padding">
|
||||
<a :href="viewCart">
|
||||
<button
|
||||
type="button"
|
||||
class="theme-btn fs16 fw6">
|
||||
{{ checkoutText }}
|
||||
</button>
|
||||
</a>
|
||||
<div class="col text-right no-padding">
|
||||
<a :href="checkoutUrl">
|
||||
<button
|
||||
type="button"
|
||||
class="theme-btn fs16 fw6">
|
||||
{{ checkoutText }}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -67,19 +69,54 @@
|
|||
<script>
|
||||
export default {
|
||||
props: [
|
||||
'items',
|
||||
'cartText',
|
||||
'viewCart',
|
||||
'removeUrl',
|
||||
'checkoutUrl',
|
||||
'cartDetails',
|
||||
'checkoutText',
|
||||
'subtotalText',
|
||||
],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
cartItems: JSON.parse(this.items),
|
||||
cartInformation: JSON.parse(this.cartDetails),
|
||||
cartItems: [],
|
||||
cartInformation: [],
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.getMiniCartDetails();
|
||||
},
|
||||
|
||||
watch: {
|
||||
'$root.miniCartKey': function () {
|
||||
this.getMiniCartDetails();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
getMiniCartDetails: function () {
|
||||
this.$http.get(`${this.$root.baseUrl}/mini-cart`)
|
||||
.then(response => {
|
||||
if (response.data.status) {
|
||||
this.cartItems = response.data.mini_cart.cart_items;
|
||||
this.cartInformation = response.data.mini_cart.cart_details;
|
||||
}
|
||||
})
|
||||
.catch(exception => {
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
},
|
||||
|
||||
removeProduct: function (productId) {
|
||||
this.$http.delete(`${this.$root.baseUrl}/cart/remove/${productId}`)
|
||||
.then(response => {
|
||||
this.cartItems = this.cartItems.filter(item => item.id != productId);
|
||||
|
||||
window.showAlert(`alert-${response.data.status}`, response.data.label, response.data.message);
|
||||
})
|
||||
.catch(exception => {
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
<span class="fs14" v-text="product.firstReviewText"></span>
|
||||
</div>
|
||||
|
||||
<vnode-injector :nodes="getAddToCartHtml()"></vnode-injector>
|
||||
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -88,22 +88,5 @@
|
|||
'showTestClass': 'sdfsdf',
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
getAddToCartHtml: function () {
|
||||
const { render, staticRenderFns } = Vue.compile(this.product.addToCartHtml);
|
||||
const _staticRenderFns = this.$options.staticRenderFns = staticRenderFns;
|
||||
|
||||
try {
|
||||
var output = render.call(this, this.$createElement)
|
||||
} catch (exception) {
|
||||
debugger
|
||||
}
|
||||
|
||||
this.$options.staticRenderFns = _staticRenderFns
|
||||
|
||||
return output
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
window.showAlert(
|
||||
'alert-danger',
|
||||
this.__('shop.general.alert.error'),
|
||||
this.__('error.something-went-wrong')
|
||||
this.__('error.something_went_wrong')
|
||||
);
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
<p class="pt14 fs14 description-text" v-html="product.shortDescription"></p>
|
||||
|
||||
<vnode-injector :nodes="getAddToCartHtml()"></vnode-injector>
|
||||
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
@ -106,21 +106,6 @@
|
|||
changeImage: function (imageIndex) {
|
||||
this.currentlyActiveImage = imageIndex;
|
||||
},
|
||||
|
||||
getAddToCartHtml: function () {
|
||||
const { render, staticRenderFns } = Vue.compile(this.product.addToCartHtml);
|
||||
const _staticRenderFns = this.$options.staticRenderFns = staticRenderFns;
|
||||
|
||||
try {
|
||||
var output = render.call(this, this.$createElement)
|
||||
} catch (exception) {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
}
|
||||
|
||||
this.$options.staticRenderFns = _staticRenderFns
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -166,16 +166,22 @@ $(document).ready(function () {
|
|||
},
|
||||
|
||||
getDynamicHTML: function (input) {
|
||||
var _staticRenderFns;
|
||||
const { render, staticRenderFns } = Vue.compile(input);
|
||||
const _staticRenderFns = this.$options.staticRenderFns = staticRenderFns;
|
||||
|
||||
try {
|
||||
var output = render.call(this, this.$createElement)
|
||||
} catch (exception) {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
if (this.$options.staticRenderFns.length > 0) {
|
||||
_staticRenderFns = this.$options.staticRenderFns;
|
||||
} else {
|
||||
_staticRenderFns = this.$options.staticRenderFns = staticRenderFns;
|
||||
}
|
||||
|
||||
this.$options.staticRenderFns = _staticRenderFns
|
||||
try {
|
||||
var output = render.call(this, this.$createElement);
|
||||
} catch (exception) {
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
}
|
||||
|
||||
this.$options.staticRenderFns = _staticRenderFns;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -189,6 +195,7 @@ $(document).ready(function () {
|
|||
data: function () {
|
||||
return {
|
||||
modalIds: {},
|
||||
miniCartKey: 0,
|
||||
quickView: false,
|
||||
productDetails: [],
|
||||
}
|
||||
|
|
@ -317,5 +324,5 @@ $(document).ready(function () {
|
|||
render(h, {props}) {
|
||||
return props.nodes;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ return [
|
|||
'error' => [
|
||||
'go-to-home' => 'الذهاب إلى المنزل',
|
||||
'page-lost-short' => 'الصفحة فقدت المحتوى',
|
||||
'something-went-wrong' => 'هناك خطأ ما',
|
||||
'something_went_wrong' => 'هناك خطأ ما',
|
||||
'page-lost-description' => "الصفحة التي تبحث عنها غير متوفرة. حاول البحث مرة أخرى أو استخدم زر العودة للخلف أدناه.",
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ return [
|
|||
'error' => [
|
||||
'go-to-home' => 'Go to home',
|
||||
'page-lost-short' => 'Page lost content',
|
||||
'something-went-wrong' => 'something went wrong',
|
||||
'something_went_wrong' => 'something went wrong',
|
||||
'page-lost-description' => "The page you're looking for isn't available. Try to search again or use the Go Back button below.",
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ return [
|
|||
'error' => [
|
||||
'go-to-home' => 'Ga naar de startpagina',
|
||||
'page-lost-short' => 'Page lost content',
|
||||
'something-went-wrong' => 'something went wrong',
|
||||
'something_went_wrong' => 'something went wrong',
|
||||
'page-lost-description' => "The page you're looking for isn't available. Try to search again or use the Go Back button below.",
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ return [
|
|||
|
||||
'error' => [
|
||||
'go-to-home' => 'Vá para casa',
|
||||
'something-went-wrong' => 'algo deu errado',
|
||||
'something_went_wrong' => 'algo deu errado',
|
||||
'page-lost-short' => 'Conteúdo perdido da página',
|
||||
'page-lost-description' => "A página que você está procurando não está disponível. Tente pesquisar novamente ou use o botão Voltar atrás abaixo.",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,133 +1,9 @@
|
|||
@inject ('productImageHelper', 'Webkul\Product\Helpers\ProductImage')
|
||||
|
||||
@php
|
||||
$cart = cart()->getCart();
|
||||
@endphp
|
||||
|
||||
<div class="mini-cart-container pull-right">
|
||||
@if ($cart)
|
||||
@php
|
||||
Cart::collectTotals();
|
||||
$items = $cart->items;
|
||||
|
||||
$cartItems = $items->toArray();
|
||||
|
||||
$cartDetails = [];
|
||||
$cartDetails['base_sub_total'] = core()->currency($cart->base_sub_total);
|
||||
@endphp
|
||||
|
||||
<div class="dropdown">
|
||||
<cart-btn item-count="{{ $cart->items->count() }}"></cart-btn>
|
||||
|
||||
@foreach ($items as $index => $item)
|
||||
@php
|
||||
$images = $item->product->getTypeInstance()->getBaseImage($item);
|
||||
|
||||
$cartItems[$index]['images'] = $images;
|
||||
$cartItems[$index]['url_key'] = $item->product->url_key;
|
||||
$cartItems[$index]['base_total'] = core()->currency($item->base_total);
|
||||
@endphp
|
||||
@endforeach
|
||||
|
||||
{{-- <div class="modal-content sensitive-modal cart-modal-content hide" id="cart-modal-content">
|
||||
<!--Body-->
|
||||
<div class="mini-cart-container">
|
||||
@foreach ($items as $item)
|
||||
@php
|
||||
$images = $item->product->getTypeInstance()->getBaseImage($item);
|
||||
@endphp
|
||||
|
||||
<div class="row small-card-container">
|
||||
<div class="col-3 product-image-container mr15">
|
||||
<a href="{{ route('shop.checkout.cart.remove', ['id' => $item->id]) }}">
|
||||
<span class="rango-close"></span>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="{{ route('shop.productOrCategory.index', $item->product->url_key) }}"
|
||||
class="unset">
|
||||
|
||||
<div class="product-image"
|
||||
style="background-image: url('{{ $images['small_image_url'] }}');">
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-9 no-padding card-body align-vertical-top">
|
||||
<div class="no-padding">
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.name.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="fs16 text-nowrap fw6">{{ $item->name }}</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.name.after', ['item' => $item]) !!}
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.price.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="fs18 card-current-price fw6">
|
||||
<div class="display-inbl">
|
||||
<label class="fw5">{{ __('velocity::app.checkout.qty') }}</label>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.quantity.before', ['item' => $item]) !!}
|
||||
|
||||
<input type="text" disabled value="{{ $item->quantity }}" class="ml5" />
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.quantity.after', ['item' => $item]) !!}
|
||||
</div>
|
||||
<span class="card-total-price fw6">
|
||||
{{ core()->currency($item->base_total) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.price.after', ['item' => $item]) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<!--Footer-->
|
||||
<div class="modal-footer">
|
||||
<h2 class="col-6 text-left fw6">
|
||||
{{ __('shop::app.checkout.cart.cart-subtotal') }}
|
||||
</h2>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.subtotal.before', ['cart' => $cart]) !!}
|
||||
|
||||
<h2 class="col-6 text-right fw6 no-padding">{{ core()->currency($cart->base_sub_total) }}</h2>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.subtotal.after', ['cart' => $cart]) !!}
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<a class="col text-left fs16 link-color remove-decoration" href="{{ route('shop.checkout.cart.index') }}">
|
||||
{{ __('shop::app.minicart.view-cart') }}
|
||||
</a>
|
||||
|
||||
<div class="col text-right no-padding">
|
||||
<a href="{{ route('shop.checkout.onepage.index') }}">
|
||||
<button
|
||||
type="button"
|
||||
class="theme-btn fs16 fw6">
|
||||
{{ __('shop::app.minicart.checkout') }}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<mini-cart
|
||||
items="{{ json_encode($cartItems) }}"
|
||||
cart-details="{{ json_encode($cartDetails) }}"
|
||||
view-cart="{{ route('shop.checkout.cart.index') }}"
|
||||
cart-text="{{ __('shop::app.minicart.view-cart') }}"
|
||||
checkout-text="{{ __('shop::app.minicart.checkout') }}"
|
||||
checkout-url="{{ route('shop.checkout.onepage.index') }}"
|
||||
subtotal-text="{{ __('shop::app.checkout.cart.cart-subtotal') }}"
|
||||
remove-url="{{ route('shop.checkout.cart.remove', ['id' => $item->id]) }}">
|
||||
</mini-cart>
|
||||
</div>
|
||||
@else
|
||||
<div class="dropdown disable-active">
|
||||
<cart-btn item-count="{{ __('shop::app.minicart.zero') }}"></cart-btn>
|
||||
</div>
|
||||
@endif
|
||||
<mini-cart
|
||||
view-cart="{{ route('shop.checkout.cart.index') }}"
|
||||
cart-text="{{ __('shop::app.minicart.view-cart') }}"
|
||||
checkout-text="{{ __('shop::app.minicart.checkout') }}"
|
||||
checkout-url="{{ route('shop.checkout.onepage.index') }}"
|
||||
subtotal-text="{{ __('shop::app.checkout.cart.cart-subtotal') }}">
|
||||
</mini-cart>
|
||||
</div>
|
||||
|
|
@ -60,9 +60,16 @@
|
|||
@elseif ($attribute['code'] == 'price')
|
||||
<span v-html="product['priceHTML']"></span>
|
||||
@elseif ($attribute['code'] == 'addToCartHtml')
|
||||
<div v-html="product['addToCartHtml']"></div>
|
||||
@include('shop::products.wishlist')
|
||||
<i class="material-icons cross fs16" @click="removeProductCompare(isCustomer ? product.id : product.slug)">close</i>
|
||||
<div class="action">
|
||||
<vnode-injector :nodes="$root.getDynamicHTML(product.addToCartHtml)"></vnode-injector>
|
||||
|
||||
<i
|
||||
class="material-icons cross fs16"
|
||||
@click="removeProductCompare(isCustomer ? product.id : product.slug)">
|
||||
|
||||
close
|
||||
</i>
|
||||
</div>
|
||||
@elseif ($attribute['code'] == 'color')
|
||||
<span v-html="product.color_label"></span>
|
||||
@elseif ($attribute['code'] == 'size')
|
||||
|
|
@ -125,10 +132,10 @@
|
|||
this.$http.get(`${this.$root.baseUrl}/comparison`, data)
|
||||
.then(response => {
|
||||
this.isProductListLoaded = true;
|
||||
this.products = response.data.products
|
||||
this.products = response.data.products;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -145,7 +152,7 @@
|
|||
window.showAlert(`alert-${response.data.status}`, response.data.label, response.data.message);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
console.log(this.__('error.something_went_wrong'));
|
||||
});
|
||||
} else {
|
||||
let existingItems = window.localStorage.getItem('compared_product');
|
||||
|
|
@ -168,21 +175,6 @@
|
|||
);
|
||||
}
|
||||
},
|
||||
|
||||
'getAddToCartHtml': function (input) {
|
||||
const { render, staticRenderFns } = Vue.compile(input);
|
||||
const _staticRenderFns = this.$options.staticRenderFns = staticRenderFns;
|
||||
|
||||
try {
|
||||
var output = render.call(this, this.$createElement)
|
||||
} catch (exception) {
|
||||
console.log(this.__('error.something-went-wrong'));
|
||||
}
|
||||
|
||||
this.$options.staticRenderFns = _staticRenderFns
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
if (messageType && message !== '') {
|
||||
let html = `<div class="alert ${messageType} alert-dismissible" id="alert">
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
<strong>${messageLabel} !</strong> ${message}.
|
||||
<strong>${messageLabel ? messageLabel + '!' : ''} </strong> ${message}.
|
||||
</div>`;
|
||||
|
||||
$('body').append(html);
|
||||
|
|
|
|||
|
|
@ -17,28 +17,7 @@
|
|||
</span>
|
||||
</button>
|
||||
@else
|
||||
<form method="POST" action="{{ route('cart.add', $product->product_id) }}">
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="quantity" value="1" />
|
||||
<input type="hidden" name="product_id" value="{{ $product->product_id }}" />
|
||||
|
||||
<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>
|
||||
|
||||
{{-- <add-to-cart
|
||||
<add-to-cart
|
||||
form="true"
|
||||
csrf-token='{{ csrf_token() }}'
|
||||
product-id="{{ $product->product_id }}"
|
||||
|
|
@ -46,26 +25,23 @@
|
|||
is-enable={{ ! $product->isSaleable() ? 'false' : 'true' }}
|
||||
show-cart-icon={{ !(isset($showCartIcon) && !$showCartIcon) }}
|
||||
btn-text="{{ $btnText ?? __('shop::app.products.add-to-cart') }}">
|
||||
</add-to-cart> --}}
|
||||
</add-to-cart>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if (isset($showCompare) && $showCompare)
|
||||
@auth('customer')
|
||||
<compare-component
|
||||
customer="true"
|
||||
product-id="{{ $product->id }}"
|
||||
slug="{{ $product->url_key }}"
|
||||
></compare-component>
|
||||
@endif
|
||||
@auth('customer')
|
||||
customer="true"
|
||||
@endif
|
||||
|
||||
@guest('customer')
|
||||
customer="false"
|
||||
@endif
|
||||
|
||||
@guest('customer')
|
||||
<compare-component
|
||||
customer="false"
|
||||
product-id="{{ $product->id }}"
|
||||
slug="{{ $product->url_key }}"
|
||||
product-id="{{ $product->id }}"
|
||||
></compare-component>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if (! (isset($showWishlist) && !$showWishlist))
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@
|
|||
},
|
||||
|
||||
mounted: function () {
|
||||
// this.open360View();
|
||||
|
||||
let currentProductId = '{{ $product->url_key }}';
|
||||
let existingViewed = window.localStorage.getItem('recentlyViewed');
|
||||
if (! existingViewed) {
|
||||
|
|
@ -250,9 +252,9 @@
|
|||
open360View: function () {
|
||||
this.slot = false;
|
||||
|
||||
$(function() {
|
||||
setTimeout(() => {
|
||||
$('.spritespin').spritespin({
|
||||
source: SpriteSpin.sourceArray('http://localhost/3d-image/sample-{lane}-{frame}.jpg', {
|
||||
source: SpriteSpin.sourceArray('http://shubham.webkul.com/3d-image/sample-{lane}-{frame}.jpg', {
|
||||
lane: [0,5],
|
||||
frame: [0,5],
|
||||
digits: 2
|
||||
|
|
@ -280,9 +282,10 @@
|
|||
'progress',
|
||||
'360',
|
||||
'drag'
|
||||
];
|
||||
]
|
||||
});
|
||||
});
|
||||
}, 0);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue