Added checks for different action if product individual view inactive.
This commit is contained in:
parent
cbe0d51a33
commit
cc8dd8bf07
|
|
@ -70,6 +70,9 @@ class WishlistController extends Controller
|
|||
return redirect()->back();
|
||||
} elseif (! $product->status) {
|
||||
return redirect()->back();
|
||||
} elseif (! $product->visible_individually) {
|
||||
session()->flash('warning', trans('shop::app.common.product-individual-view-inactive'));
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ class CartController extends Controller
|
|||
public function add($id)
|
||||
{
|
||||
try {
|
||||
if ($product = $this->productRepository->findOrFail($id)) {
|
||||
if (! $product->visible_individually) {
|
||||
session()->flash('warning', trans('shop::app.common.product-individual-view-inactive'));
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
Cart::deactivateCurrentCartIfBuyNowIsActive();
|
||||
|
||||
$result = Cart::addProduct($id, request()->all());
|
||||
|
|
|
|||
|
|
@ -7,18 +7,22 @@ use Webkul\Attribute\Repositories\AttributeRepository;
|
|||
use Webkul\Product\Repositories\ProductAttributeValueRepository;
|
||||
use Webkul\Product\Repositories\ProductDownloadableLinkRepository;
|
||||
use Webkul\Product\Repositories\ProductDownloadableSampleRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Product\Repositories\ProductAttributeValueRepository $productAttributeValueRepository
|
||||
* @param \Webkul\Product\Repositories\ProductDownloadableSampleRepository $productDownloadableSampleRepository
|
||||
* @param \Webkul\Product\Repositories\ProductDownloadableLinkRepository $productDownloadableLinkRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ProductRepository $productRepository,
|
||||
protected ProductAttributeValueRepository $productAttributeValueRepository,
|
||||
protected ProductDownloadableSampleRepository $productDownloadableSampleRepository,
|
||||
protected ProductDownloadableLinkRepository $productDownloadableLinkRepository
|
||||
|
|
@ -75,6 +79,13 @@ class ProductController extends Controller
|
|||
} else {
|
||||
$productDownloadableSample = $this->productDownloadableSampleRepository->findOrFail(request('id'));
|
||||
|
||||
if ($product = $this->productRepository->findOrFail($productDownloadableSample->product_id)) {
|
||||
if (! $product->visible_individually) {
|
||||
session()->flash('warning', trans('shop::app.common.product-individual-view-inactive'));
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
if ($productDownloadableSample->type == 'file') {
|
||||
return Storage::download($productDownloadableSample->file);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,13 @@ class ComparisonController extends Controller
|
|||
|
||||
$customerId = auth()->guard('customer')->user()->id;
|
||||
|
||||
if ($product = $this->productRepository->findOrFail($productId)) {
|
||||
if (! $product->visible_individually) {
|
||||
session()->flash('warning', trans('shop::app.common.product-individual-view-inactive'));
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
$compareProduct = $this->compareProductsRepository->findOneByField([
|
||||
'customer_id' => $customerId,
|
||||
'product_id' => $productId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue