feat(categories): add options to select what categories to show on front page
This commit is contained in:
@@ -82,6 +82,7 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
$this->load->model('setting/setting');
|
||||
$this->load->model('tool/image');
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('catalog/category');
|
||||
$this->load->model('localisation/order_status');
|
||||
$this->load->model('customer/customer_group');
|
||||
}
|
||||
@@ -149,6 +150,17 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
'name' => $productItem['name'],
|
||||
];
|
||||
}
|
||||
} elseif ($config['type'] === 'categories') {
|
||||
$categories = $this->request->post[$key] ?? $this->config->get($key) ?? [];
|
||||
|
||||
$data[$key] = [];
|
||||
foreach ($categories as $categoryId) {
|
||||
$categoryItem = $this->model_catalog_category->getCategory($categoryId);
|
||||
$data[$key][] = [
|
||||
'category_id' => $categoryId,
|
||||
'name' => $categoryItem['name'],
|
||||
];
|
||||
}
|
||||
} elseif (isset($this->request->post[$key])) {
|
||||
$data[$key] = $this->request->post[$key];
|
||||
} else {
|
||||
@@ -326,6 +338,7 @@ TEXT,
|
||||
'module_tgshop_order_customer_group_id' => 1,
|
||||
'module_tgshop_order_default_status_id' => 1,
|
||||
'module_tgshop_mini_app_url' => rtrim(HTTPS_CATALOG, '/') . '/image/catalog/tgshopspa/#/',
|
||||
'module_tgshop_mainpage_categories' => 'latest10'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -438,6 +451,21 @@ HTML,
|
||||
'type' => 'products',
|
||||
'help' => 'На главной странице будут отображаться избранные товары, если вы выберете этот вариант в настройке “Товары на главной”.',
|
||||
],
|
||||
|
||||
'module_tgshop_mainpage_categories' => [
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
'no_categories' => 'Отображать только кнопку "Каталог"',
|
||||
'latest10' => 'Последние 10 категорий',
|
||||
'featured' => 'Избранные категории (задать в поле ниже)',
|
||||
],
|
||||
'help' => 'Выберите, какие категории показывать на главной странице магазина в Telegram. Это влияет на первую видимую секцию каталога для пользователя.',
|
||||
],
|
||||
|
||||
'module_tgshop_featured_categories' => [
|
||||
'type' => 'categories',
|
||||
'help' => 'На главной странице будут отображаться эти категории, если вы выберете этот вариант в настройке “Категории на главной”.',
|
||||
],
|
||||
],
|
||||
|
||||
'orders' => [
|
||||
|
||||
@@ -27,6 +27,8 @@ $_['lbl_module_tgshop_featured_products'] = 'Избранные товары';
|
||||
$_['lbl_module_tgshop_order_customer_group_id'] = 'Группа покупателей';
|
||||
$_['lbl_module_tgshop_order_default_status_id'] = 'Статус заказов';
|
||||
$_['lbl_module_tgshop_mini_app_url'] = 'Ссылка на Telegram Mini App';
|
||||
$_['lbl_module_tgshop_mainpage_categories'] = 'Категории на главной';
|
||||
$_['lbl_module_tgshop_featured_categories'] = 'Избранные категории';
|
||||
|
||||
// Entry
|
||||
$_['entry_status'] = 'Статус';
|
||||
|
||||
@@ -144,6 +144,43 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{% elseif item['type'] == 'categories' %}
|
||||
<input type="text" value="" placeholder="Начните вводить название категории..." id="{{ settingKey }}-input" class="form-control"/>
|
||||
<div id="{{ settingKey }}-list" class="well well-sm" style="height: 150px; overflow: auto;">
|
||||
{% for category in attribute(_context, settingKey) %}
|
||||
<div id="{{ settingKey }}-{{ category.category_id }}">
|
||||
<i class="fa fa-minus-circle"></i> {{ category.name }}
|
||||
<input type="hidden" name="{{ settingKey }}[]" value="{{ category.category_id }}"/>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
$('#{{ settingKey }}-input').autocomplete({
|
||||
'source': function(request, response) {
|
||||
$.ajax({
|
||||
url: 'index.php?route=catalog/category/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
response($.map(json, function(item) {
|
||||
return {
|
||||
label: item['name'],
|
||||
value: item['category_id']
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
'select': function(item) {
|
||||
$('#{{ settingKey }}').val('');
|
||||
$('#{{ settingKey }}-' + item['value']).remove();
|
||||
$('#{{ settingKey }}-list').append('<div id="{{ settingKey }}-' + item['value'] + '"><i class="fa fa-minus-circle"></i> ' + item['label'] + '<input type="hidden" name="{{ settingKey }}[]" value="' + item['value'] + '" /></div>');
|
||||
}
|
||||
});
|
||||
|
||||
$('#{{ settingKey }}-list').delegate('.fa-minus-circle', 'click', function() {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
</script>
|
||||
{# ChatID #}
|
||||
{% elseif item['type'] == 'chatid' %}
|
||||
{% if module_tgshop_bot_token %}
|
||||
|
||||
Reference in New Issue
Block a user