Примерочная

This commit is contained in:
Konstantin
2026-05-31 11:45:21 +03:00
parent 42062344a1
commit 5a677f7db7
4 changed files with 275 additions and 32 deletions
+78 -13
View File
@@ -19,14 +19,23 @@ class ControllerAccountWishList extends Controller {
$this->load->model('tool/image');
if (isset($this->request->get['remove'])) {
// Remove Wishlist
$this->model_account_wishlist->deleteWishlist($this->request->get['remove']);
$this->deleteWishlist((int)$this->request->get['remove']);
$this->session->data['success'] = $this->language->get('text_remove');
$this->response->redirect($this->url->link('account/wishlist'));
}
if (isset($this->request->get['clear'])) {
foreach ($this->getWishlistProductIds() as $product_id) {
$this->deleteWishlist($product_id);
}
$this->session->data['success'] = $this->language->get('text_clear');
$this->response->redirect($this->url->link('account/wishlist'));
}
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
@@ -57,18 +66,32 @@ class ControllerAccountWishList extends Controller {
$data['products'] = array();
$results = $this->session->data['wishlist'] ? $this->session->data['wishlist'] : [];
$results = $this->getWishlistProductIds();
foreach ($results as $result) {
$product_info = $this->model_catalog_product->getProduct($result);
foreach ($results as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_height'));
} else {
$image = false;
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_height'));
}
$product_images = $this->model_catalog_product->getProductImages($product_info['product_id']);
if ($product_images) {
$additional_image = $this->model_tool_image->resize($product_images[0]['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_height'));
} else {
$additional_image = false;
}
$rent_prices = array_filter(array($product_info['price'], $product_info['price_2']), function($price) {
return (float)$price > 0;
});
$min_rent_price = $rent_prices ? min($rent_prices) : 0;
if ($product_info['quantity'] <= 0) {
$stock = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
@@ -92,20 +115,27 @@ class ControllerAccountWishList extends Controller {
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'additional_thumb' => $additional_image,
'name' => $product_info['name'],
'model' => $product_info['model'],
'stock' => $stock,
'price' => $price,
'price_n' => $product_info['price'],
'price_2_n' => $product_info['price_2'],
'price_3' => $this->currency->format($this->tax->calculate($product_info['price_3'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
'min_price' => $this->currency->format($this->tax->calculate($min_rent_price, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
'special' => $special,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
'remove' => $this->url->link('account/wishlist', 'remove=' . $product_info['product_id'])
);
} else {
$this->model_account_wishlist->deleteWishlist($result);
$this->deleteWishlist($product_id);
}
}
$data['continue'] = $this->url->link('account/account', '', true);
$data['fitting_room_count'] = count($data['products']);
$data['clear'] = $this->url->link('account/wishlist', 'clear=1');
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
@@ -133,22 +163,57 @@ class ControllerAccountWishList extends Controller {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if (!isset($this->session->data['wishlist'])) {
if ($this->customer->isLogged()) {
$this->load->model('account/wishlist');
$this->model_account_wishlist->addWishlist($product_id);
$total = $this->model_account_wishlist->getTotalWishlist();
} else {
if (!isset($this->session->data['wishlist']) || !is_array($this->session->data['wishlist'])) {
$this->session->data['wishlist'] = array();
}
$this->session->data['wishlist'][] = $this->request->post['product_id'];
$this->session->data['wishlist'][] = $product_id;
$this->session->data['wishlist'] = array_unique($this->session->data['wishlist']);
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
$total = count($this->session->data['wishlist']);
}
$json['total'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . (int)$product_id), $product_info['name'], $this->url->link('account/wishlist'));
$json['total'] = sprintf($this->language->get('text_wishlist'), $total);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
private function getWishlistProductIds() {
if ($this->customer->isLogged()) {
$product_ids = array();
foreach ($this->model_account_wishlist->getWishlist() as $result) {
$product_ids[] = (int)$result['product_id'];
}
return $product_ids;
}
if (isset($this->session->data['wishlist']) && is_array($this->session->data['wishlist'])) {
return array_map('intval', $this->session->data['wishlist']);
}
return array();
}
private function deleteWishlist($product_id) {
if ($this->customer->isLogged()) {
$this->model_account_wishlist->deleteWishlist($product_id);
} elseif (isset($this->session->data['wishlist']) && is_array($this->session->data['wishlist'])) {
$this->session->data['wishlist'] = array_values(array_diff($this->session->data['wishlist'], array($product_id)));
}
}
public function old_add() {
$this->load->language('account/wishlist');
@@ -3,16 +3,29 @@
// * @license GNU General Public License version 3; see LICENSE.txt
// Heading
$_['heading_title'] = 'Мои закладки';
$_['heading_title'] = 'Виртуальная примерочная';
// Text
$_['text_account'] = 'Личный кабинет';
$_['text_instock'] = 'В наличии';
$_['text_wishlist'] = 'Закладки (%s)';
$_['text_login'] = 'Необходимо войти в <a href="%s">Личный Кабинет</a> или <a href="%s">создать учетную запись</a>, чтобы сохранить товар <a href="%s">%s</a> в свои <a href="%s">закладки</a>!';
$_['text_success'] = 'Платье <a href="%s">%s</a> было добавлен в <a href="%s">закладки</a>!';
$_['text_remove'] = 'Платье <a href="%s">%s</a> было удалено из <a href="%s">закладок</a>!';
$_['text_empty'] = 'Ваши закладки пусты.';
$_['text_wishlist'] = 'Примерочная (%s)';
$_['text_login'] = 'Необходимо войти в <a href="%s">Личный Кабинет</a> или <a href="%s">создать учетную запись</a>, чтобы сохранить платье <a href="%s">%s</a> в своей <a href="%s">примерочной</a>!';
$_['text_success'] = 'Платье <a href="%s">%s</a> добавлено в <a href="%s">примерочную</a>.';
$_['text_remove'] = 'Платье удалено из примерочной.';
$_['text_clear'] = 'Примерочная очищена.';
$_['text_eyebrow'] = 'Ваш выбор';
$_['text_intro'] = 'Соберите платья, которые хочется примерить. Отправьте одну заявку, и мы свяжемся с вами, чтобы подобрать удобное время.';
$_['text_selected'] = 'выбрано для примерки';
$_['text_request_note'] = 'Список выбранных платьев будет приложен к заявке.';
$_['text_hint'] = 'Можно убрать лишнее или продолжить выбирать платья в каталоге.';
$_['text_empty'] = 'В примерочной пока пусто';
$_['text_empty_description'] = 'Добавляйте понравившиеся платья сердечком в каталоге. Они соберутся здесь, чтобы записаться на одну удобную примерку.';
$_['text_clear_confirm'] = 'Очистить примерочную?';
// Buttons
$_['button_request'] = 'Записаться на примерку';
$_['button_clear'] = 'Очистить примерочную';
$_['button_remove'] = 'Убрать';
// Column
$_['column_image'] = 'Изображение';
@@ -358,6 +358,147 @@ header .menu>li:last-child {
}
}
.fitting-room {
background: linear-gradient(180deg, #f8f6f5 0, #fff 360px);
}
.fitting-room__hero {
display: grid;
grid-template-columns: minmax(0, 1fr) 320px;
gap: 56px;
align-items: center;
padding: 34px 0 48px;
}
.fitting-room__eyebrow {
margin-bottom: 12px;
color: #8f817d;
font-size: 12px;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.fitting-room__hero h1 {
max-width: 700px;
margin-bottom: 16px;
font-size: clamp(42px, 6vw, 76px);
line-height: 0.98;
}
.fitting-room__hero p {
max-width: 680px;
margin: 0;
color: #5c5950;
font-size: 18px;
line-height: 1.6;
}
.fitting-room__summary {
padding: 26px;
background: #fff;
border: 1px solid rgba(216, 206, 203, 0.82);
box-shadow: 0 18px 45px rgba(52, 43, 40, 0.08);
text-align: center;
}
.fitting-room__count {
font-size: 56px;
line-height: 1;
}
.fitting-room__note {
margin-top: 12px;
color: #8f817d;
font-size: 13px;
line-height: 1.45;
}
.fitting-room__toolbar {
display: flex;
gap: 18px;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
color: #5c5950;
}
.fitting-room__clear,
.fitting-room__remove {
color: #8f817d;
font-size: 13px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.fitting-room__item {
position: relative;
height: 100%;
background: #fff;
}
.fitting-room__remove {
position: absolute;
right: 14px;
bottom: 14px;
z-index: 2;
padding: 8px 10px;
background: rgba(255, 255, 255, 0.92);
}
.fitting-room__empty {
max-width: 620px;
padding: 54px 0 86px;
}
.fitting-room__empty-icon {
margin-bottom: 12px;
color: #d8cecb;
font-size: 76px;
line-height: 1;
}
.fitting-room__empty h2 {
font-size: 34px;
}
.fitting-room__empty p {
color: #5c5950;
font-size: 17px;
line-height: 1.6;
}
@media (max-width: 767px) {
.fitting-room__hero {
grid-template-columns: 1fr;
gap: 24px;
padding: 20px 0 34px;
}
.fitting-room__hero h1 {
font-size: 48px;
}
.fitting-room__hero p {
font-size: 16px;
}
.fitting-room__toolbar {
display: block;
}
.fitting-room__clear {
display: inline-block;
margin-top: 10px;
}
.fitting-room__remove {
right: 8px;
bottom: 8px;
padding: 6px 8px;
font-size: 11px;
}
}
.bg-dominik{
background-color: var(--color-secondary);
}
@@ -1,28 +1,52 @@
{{ header }}
{{ content_top }}
<section class="section-wishlist py-5">
<section class="section-wishlist fitting-room py-5">
<div class="container-fluid" id="section-wishlist">
<ul class="breadcrumb">
{% for key,breadcrumb in breadcrumbs %}
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a>{% if key + 1 < breadcrumbs|length %}<span class="mx-2">•</span>{% endif %}</li>
{% endfor %}
</ul>
<h1 class="mb-5">{{ heading_title }}</h1>
<div class="fitting-room__hero">
<div>
<div class="fitting-room__eyebrow">{{ text_eyebrow }}</div>
<h1>{{ heading_title }}</h1>
<p>{{ text_intro }}</p>
</div>
{% if products %}
<div class="fitting-room__summary">
<div class="fitting-room__count">{{ fitting_room_count }}</div>
<div>{{ text_selected }}</div>
<button type="button" class="btn btn-dark w-100 mt-3" onclick="SendRequest(0, 'fitting_room')">{{ button_request }}</button>
<div class="fitting-room__note">{{ text_request_note }}</div>
</div>
{% endif %}
</div>
{% if products %}
<div class="fitting-room__toolbar">
<div>{{ text_hint }}</div>
<a href="{{ clear }}" class="fitting-room__clear" onclick="return confirm('{{ text_clear_confirm|e('js') }}');">{{ button_clear }}</a>
</div>
<div class="row g-3 product-items">
{% for product in products %}
<div class="col-6 col-lg-4">
<div class="fitting-room__item">
{% include 'dominik/template/common/product.twig' %}
<a href="{{ product.remove }}" class="fitting-room__remove" aria-label="{{ button_remove }}: {{ product.name }}">{{ button_remove }}</a>
</div>
</div>
{% endfor %}
</div>
{% else %}
<p>{{ text_empty }}</p>
<a href="{{ continue }}" class="btn btn-dark">{{ button_continue }}</a>
<div class="fitting-room__empty">
<div class="fitting-room__empty-icon">♡</div>
<h2>{{ text_empty }}</h2>
<p>{{ text_empty_description }}</p>
<a href="{{ continue }}" class="btn btn-dark mt-3">{{ button_continue }}</a>
</div>
{% endif %}
</div>
</section>