feat: add setting to control category products button visibility

- Add show_category_products_button field to StoreDTO
- Update SettingsSerializerService to support new field
- Add setting in admin panel on 'Store' tab with toggle
- Pass setting to SPA through SettingsHandler
- Button displays only for categories with child categories
- Add default value true to configuration
This commit is contained in:
2025-12-24 01:45:50 +03:00
parent 7b0e5f80e9
commit c3994b2291
9 changed files with 50 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ HTML,
'enable_store' => true,
'feature_coupons' => true,
'feature_vouchers' => true,
'show_category_products_button' => true,
],
'texts' => [

View File

@@ -7,6 +7,7 @@ final class StoreDTO
private bool $enableStore;
private bool $featureCoupons;
private bool $featureVouchers;
private bool $showCategoryProductsButton;
private string $ocDefaultCurrency;
private bool $ocConfigTax;
private int $ocStoreId;
@@ -15,6 +16,7 @@ final class StoreDTO
bool $enableStore,
bool $featureCoupons,
bool $featureVouchers,
bool $showCategoryProductsButton,
string $ocDefaultCurrency,
bool $ocConfigTax,
int $ocStoreId
@@ -22,6 +24,7 @@ final class StoreDTO
$this->enableStore = $enableStore;
$this->featureCoupons = $featureCoupons;
$this->featureVouchers = $featureVouchers;
$this->showCategoryProductsButton = $showCategoryProductsButton;
$this->ocDefaultCurrency = $ocDefaultCurrency;
$this->ocConfigTax = $ocConfigTax;
$this->ocStoreId = $ocStoreId;
@@ -42,6 +45,11 @@ final class StoreDTO
return $this->featureVouchers;
}
public function isShowCategoryProductsButton(): bool
{
return $this->showCategoryProductsButton;
}
public function getOcDefaultCurrency(): string
{
return $this->ocDefaultCurrency;
@@ -63,6 +71,7 @@ final class StoreDTO
'enable_store' => $this->enableStore,
'feature_coupons' => $this->featureCoupons,
'feature_vouchers' => $this->featureVouchers,
'show_category_products_button' => $this->showCategoryProductsButton,
'oc_default_currency' => $this->ocDefaultCurrency,
'oc_config_tax' => $this->ocConfigTax,
'oc_store_id' => $this->ocStoreId,

View File

@@ -48,6 +48,7 @@ class SettingsHandler
'store_enabled' => $this->settings->config()->getStore()->isEnableStore(),
'feature_coupons' => $this->settings->config()->getStore()->isFeatureCoupons(),
'feature_vouchers' => $this->settings->config()->getStore()->isFeatureVouchers(),
'show_category_products_button' => $this->settings->config()->getStore()->isShowCategoryProductsButton(),
'currency_code' => $this->settings->config()->getStore()->getOcDefaultCurrency(),
'texts' => $this->settings->config()->getTexts()->toArray(),
'mainpage_blocks' => $this->settings->get('mainpage_blocks', []),

View File

@@ -141,6 +141,7 @@ class SettingsSerializerService
$data['enable_store'] ?? true,
$data['feature_coupons'] ?? true,
$data['feature_vouchers'] ?? true,
$data['show_category_products_button'] ?? true,
$data['oc_default_currency'],
$data['oc_config_tax'],
$data['oc_store_id']
@@ -281,6 +282,10 @@ class SettingsSerializerService
throw new InvalidArgumentException('store.feature_vouchers must be a boolean');
}
if (isset($data['show_category_products_button']) && ! is_bool($data['show_category_products_button'])) {
throw new InvalidArgumentException('store.show_category_products_button must be a boolean');
}
if (! isset($data['oc_default_currency'])) {
throw new InvalidArgumentException('store.oc_default_currency is required');
}