new check for kashkol 3
This commit is contained in:
@@ -152,18 +152,38 @@ class ProductController extends SuperController
|
|||||||
|
|
||||||
public function listProduct()
|
public function listProduct()
|
||||||
{
|
{
|
||||||
|
$isCustomerApi = str_contains(request()->path(), '/customer/');
|
||||||
|
$config = app(ConfigService::class);
|
||||||
|
$isStore = $config->isStore();
|
||||||
|
|
||||||
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
|
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
|
||||||
if (!str_contains(request()->path(), '/customer/')) {
|
if (! $isCustomerApi) {
|
||||||
app(\App\Services\ProductPriceSyncService::class)->syncAll(false);
|
app(\App\Services\ProductPriceSyncService::class)->syncAll(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// فروشگاه (قطره / کشکول): مثل ghatre — show بر اساس ساعت auto_open/auto_close
|
||||||
|
if ($isCustomerApi && $isStore) {
|
||||||
|
$this->auto_close_open();
|
||||||
|
}
|
||||||
|
|
||||||
$products = Product::with(['file'])->where('active', 1)->get();
|
$products = Product::with(['file'])->where('active', 1)->get();
|
||||||
|
|
||||||
if (str_contains(request()->path(), '/customer/')) {
|
if ($isCustomerApi) {
|
||||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||||
$displayPriceService->enrichForApi($products);
|
$displayPriceService->enrichForApi($products);
|
||||||
$products->each(function (Product $product) use ($displayPriceService) {
|
$showLastPrice = $config->getBool('show_last_price', false);
|
||||||
if (!$displayPriceService->hasCustomerDisplayPrice($product)) {
|
|
||||||
|
$products->each(function (Product $product) use ($displayPriceService, $isStore, $showLastPrice) {
|
||||||
|
if ($isStore) {
|
||||||
|
// فقط وقتی قیمت صفر است و fallback آخرین قیمت هم خاموش است
|
||||||
|
if (! $displayPriceService->hasCustomerDisplayPrice($product) && ! $showLastPrice) {
|
||||||
|
$product->setAttribute('show', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
|
||||||
$product->setAttribute('show', false);
|
$product->setAttribute('show', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user