feat(telecart): add vouchers and coupons (#9)

This commit is contained in:
2025-10-20 20:00:31 +03:00
parent 78ca4fd309
commit ac24f0376b
10 changed files with 149 additions and 14 deletions

View File

@@ -348,11 +348,24 @@ TEXT,
'module_tgshop_mini_app_url' => rtrim(HTTPS_CATALOG, '/') . '/image/catalog/tgshopspa/#/',
'module_tgshop_mainpage_categories' => 'latest10',
'module_tgshop_enable_store' => 1,
'module_tgshop_feature_coupons' => 0,
'module_tgshop_feature_vouchers' => 0,
];
}
private function getSettingsConfig(): array
{
$ocCouponsLink = $this->url->link(
'marketing/coupon',
'user_token=' . $this->session->data['user_token'],
true
);
$ocVouchersLink = $this->url->link(
'sale/voucher',
'user_token=' . $this->session->data['user_token'],
true
);
return [
'general' => [
'module_tgshop_status' => [
@@ -486,6 +499,28 @@ HTML,
'type' => 'categories',
'help' => 'На главной странице будут отображаться эти категории, если вы выберете этот вариант в настройке “Категории на главной”.',
],
'module_tgshop_feature_coupons' => [
'type' => 'select',
'options' => [
0 => 'Выключено',
1 => 'Включено',
],
'help' => <<<HTML
Позволяет использовать стандартные <a href="{$ocCouponsLink}" target="_blank">купоны OpenCart</a> для предоставления скидок при оформлении заказа.
HTML,
],
'module_tgshop_feature_vouchers' => [
'type' => 'select',
'options' => [
0 => 'Выключено',
1 => 'Включено',
],
'help' => <<<HTML
Позволяет покупателям использовать <a href="{$ocVouchersLink}" target="_blank">подарочные сертификаты OpenCart</a> при оформлении заказа.
HTML,
],
],
'orders' => [

View File

@@ -30,6 +30,8 @@ $_['lbl_module_tgshop_mini_app_url'] = 'Ссылка на Telegram Mini App';
$_['lbl_module_tgshop_mainpage_categories'] = 'Категории на главной';
$_['lbl_module_tgshop_featured_categories'] = 'Избранные категории';
$_['lbl_module_tgshop_enable_store'] = 'Разрешить покупки';
$_['lbl_module_tgshop_feature_coupons'] = 'Промокоды';
$_['lbl_module_tgshop_feature_vouchers'] = 'Подарочные сертификаты';
// Entry
$_['entry_status'] = 'Статус';

View File

@@ -83,23 +83,30 @@ class ControllerExtensionTgshopHandle extends Controller
],
'cache_categories_main' => 60 * 10,
'cache_products_main' => 60 * 10,
'feature_coupons' => filter_var(
$this->config->get('module_tgshop_feature_coupons'),
FILTER_VALIDATE_BOOLEAN
),
'feature_vouchers' => filter_var(
$this->config->get('module_tgshop_feature_vouchers'),
FILTER_VALIDATE_BOOLEAN
),
]);
$app->bind(OcModelCatalogProductAdapter::class, function () {
return new OcModelCatalogProductAdapter($this->model_catalog_product);
});
$app->bind(Url::class, fn () => $this->url);
$app->bind(Currency::class, fn () => $this->currency);
$app->bind(Tax::class, fn () => $this->tax);
$app->bind(ImageToolInterface::class, fn () => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
$app->bind(Cart::class, fn () => $this->cart);
$app->bind(OcRegistryDecorator::class, fn () => new OcRegistryDecorator($this->registry));
$app->singleton(Log::class, fn () => $this->log);
$app->bind(Url::class, fn() => $this->url);
$app->bind(Currency::class, fn() => $this->currency);
$app->bind(Tax::class, fn() => $this->tax);
$app->bind(ImageToolInterface::class, fn() => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
$app->bind(Cart::class, fn() => $this->cart);
$app->bind(OcRegistryDecorator::class, fn() => new OcRegistryDecorator($this->registry));
$app->singleton(Log::class, fn() => $this->log);
$app
->withLogger(fn () => new OpenCartLogAdapter($this->log, 'TeleCart'))
->withLogger(fn() => new OpenCartLogAdapter($this->log, 'TeleCart'))
->bootAndHandleRequest();
}

View File

@@ -52,6 +52,8 @@ class SettingsHandler
'ya_metrika_enabled' => $this->settings->get('ya_metrika_enabled'),
'app_enabled' => $this->settings->get('app_enabled'),
'store_enabled' => $this->settings->get('store_enabled'),
'feature_coupons' => $this->settings->get('feature_coupons') ?? false,
'feature_vouchers' => $this->settings->get('feature_vouchers') ?? false,
]);
}