Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

kuripka2222

Користувачі
  
  • Публікації

    136
  • З нами

  • Відвідування

Усі публікації користувача kuripka2222

  1. Здравствуйте, версия опенкарта 3.0.3.6. При импорте по такой конструкции, страница модуля перестает отвечать, пишет - Страница недоступна. Подскажите, пожалуйста, почему возникает такая проблема? {% import "extension/module/Html.twig" as imform %} а в файле, к примеру так <p>{{ imform.input('username') }}</p>
  2. kuripka2222

    Ошибка в ajax

    Здравствуйте, помогите разобраться в чем ошибка В консоле показывает ошибку jquery-3.5.1.min.js:2 GET index.php?route=product/product/quick_view&product_id=50 send @ jquery-3.5.1.min.js:2 ajax @ jquery-3.5.1.min.js:2 S.fn.load @ jquery-3.5.1.min.js:2 open_quick_view @ quick_view.js:33 onclick @ tablet:1 в quick_view.js:33 находится: function open_quick_view(p_id) { $('.show_quick_view').load('index.php?route=product/product/quick_view&product_id='+p_id, function() { $(".quick_view .image-additional").mCustomScrollbar({ axis:'x', advanced:{ updateOnImageLoad: true, autoExpandHorizontalScroll:false }, theme:'dark-3' }); var a = $('.quick_view .image-additional2 img').length*88; var b = ($('.quick_view .image-additional2 img').length-1)*10; $('.quick_view .image-additional2').css('width', a+b); $('.quick_view .scroll').mCustomScrollbar({ axis:'y', autoExpandHorizontalScroll:true, theme:"dark" }); if ($('.quick_view .image-additional img').length < 5) { $('.quick_view .social').css('margin-top', '-2px') } $('.show_quick_view').popup('show'); $('.image-additional2 img').bind('click', function (){ $('.quick_view .left .image img').attr('src', $(this).attr('data-thumb')); }); }); }
  3. Спасибо большое, все получилось)
  4. Добрый день, у меня есть строки {% if product.stock <=5 %}{% endif %} и {% if product.stock >=5 %}{% endif %} Как я могу сделать чтобы было больше 0, но не боле 5?
  5. Добрый день, помогите перевести строку с php в twig <?php echo implode('<br />', $download['serials']); ?>
  6. Мне нужно убрать из модуля настройки высоты и ширины, так как когда в настройках выставляешь 300 х 400 px, картинка обрезается, это хорошо в категориях к примеру, но в баннерах это очень неудобно, так как загружаешь свои картинки, уже с подготовленными размерами. Я сейчас делают слайдер на всю ширину экрана и из-за этих настроек я не могу на всю ширину сделать картинку в слайдере. Я хочу настраивать слайдер стилями а не настройками. Я сейчас сделал так, в файле catalog/model/image.php закомментировал $image->resize($width, $height); и в контроллере модуля слайдер изменил с 'image' => $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']) на 'image' => $this->model_tool_image->resize($result['image'],0,120) Так и оставить или есть более правильное решение?
  7. Здравствуйте, форумчане! Подскажите пожалуйста как можно избавиться от * $setting['width'], $setting['height'] * в модулях, типа слайдшоу, баннеры и тд. И задавать свои размеры через css, либо устанавливать размеры в настройках не в px а в процентах (%)?? Я думаю, что многие сталкивались с этим вопросом, так как максимально не удобно выставлять один размер для всех расширений экрана, к примеру выставил баннер 1200px на 400, в телефоне он уменьшается по ширине, а высота слайдера остается такой же, но с белым фоном
  8. Добрый день 1. В файле catalog/controller/mail/order.php найдите: 'image' => ($product_info['image']) ? $this->model_tool_image->resize($product_info['image'], 100, 100) : '', и замените на : 'image' => ($product_info['image']) ? $this->model_tool_image->resize($product_info['image'], 50, 50) : '', 2. В файле catalog/controller/account/order.php найдите: $thumb = $this->model_tool_image->resize($product_info['image'], 100, 100); и замените на: $thumb = $this->model_tool_image->resize($product_info['image'], 50, 50); После обновите модификаторы проверяйте. Вообще, размеры картинки указаны в пикселях, где *100, 100* и *50, 50*, вы можете поиграться с размерами и, к примеру, указать *70, 50*, на сайте это будет картинка с шириной 70px и высотой 50px
  9. Все получилось, спасибо! Если кому-то надо для Opencart 3 версии показывать все заказы на карте (в данном случае Яндекс.Карты), могу выложить в эту же тему модуль. Пример на скриншоте:
  10. Здравствуйте, я уже все форумы пересмотрел в поисках преобразования в TWIG, может кто знает как перевести значение: <?php echo urlencode(json_encode($map_setting)); ?> Я перевожу его как код ниже, но страница на сайте, где выводится модуль после этого не отвечает {{ urlencode(json_encode(map_setting)) }}
  11. Здравствуйте, подскажите пожалуйста как мне добавить фотографию(маленькую миниатюрку) предыдущего и следующего товара ?? Я в product.php вывожу так: // if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } } $category_id = array_pop($parts); $category_link = "&path=".$category_id; } else { $category_id = 0; $category_link = ""; } $data[] = array( 'filter_category_id' => $category_id, 'product_id' => $product_id ); $results = $this->model_catalog_product->PreNextbyCat($data); if(isset($results['next']) && isset($results['next_name'])){ $data['next_link'] = "<a href=".$this->url->link('product/product',$category_link.'&product_id='.$results['next']).">".$results['next_name']." <i class='fa fa-chevron-right'></i></a>"; }else{ $data['next_link'] = null; } if(isset($results['prev']) && isset($results['prev_name'])){ $data['prev_link'] = "<a href=".$this->url->link('product/product',$category_link.'&product_id='.$results['prev'])."><i class='fa fa-chevron-left'></i> ".$results['prev_name']."</a>"; }else{ $data['prev_link'] = null; } // А в product.twig вывожу так : <ul class="ul-next-right"> {% if prev_link %} <li class="next-prev-class" data-toggle="tooltip" data-html="true" title="Предыдущий товар:<img class='d-block m-1 mx-auto' src='...'>"><span class="span-next-prev">{{ prev_link }}</span></li> {% endif %} {% if next_link %} <li class="next-prev-class" data-toggle="tooltip" data-html="true" data-title="Следующий товар:<img class='d-block m-1 mx-auto' src='...'>">{{ next_link }}</span></li> {% endif %} </ul>
  12. Мне этот код нужен как раз для Opencart 3. Я хочу вывести пользовательскую страницу с ajax подгрузкой всех товаров, но где-то еще ошибка в коде
  13. Спасибо, а не подскажете где в коде ошибка еще ? Страница на сайте недоступна <?php // catalog/controller/ajax/index.php class ControllerAjaxIndex extends Controller { public function index() { $this->load->language('ajax/index'); $this->load->model('catalog/product'); $this->document->setTitle($this->language->get('heading_title')); // загружаем все товары $products = $this->model_catalog_product->getProducts(); $data['products'] = $products; $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'href' => $this->url->link('common/home'), 'text' => $this->language->get('text_home') ); $data['breadcrumbs'][] = array( 'href' => $this->url->link('ajax/index'), 'text' => $this->language->get('heading_title') ); $data['heading_title'] = $this->language->get('heading_title'); $data['text_product_dropdown_label'] = $this->language->get('text_product_dropdown_label'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/ajax/index')) { $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/ajax/index', $data)); } else { $this->response->setOutput($this->load->view('default/template/ajax/index', $data)); } } // метод вызова ajax public function ajaxGetProduct() { if (isset($this->request->get['product_id'])) { $product_id = (int) $this->request->get['product_id']; if ($product_id > 0) { // загружаем определенный товар, запрошенный в ajax $this->load->model('catalog/product'); $product = $this->model_catalog_product->getProduct($product_id); $data['product'] = $product; // подготавливаем превью изображения $this->load->model('tool/image'); if ($product['image']) { $data['thumb'] = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')); } // форматируем цену $data['price'] = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))); $this->load->language('product/product'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_note'] = $this->language->get('text_note'); $data['tab_description'] = $this->language->get('tab_description'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/ajax/product')) { $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/ajax/product', $data)); } else { $this->response->setOutput($this->load->view('default/template/ajax/product', $data)); } } } } $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); }
  14. kuripka2222

    Ошибка в php

    Здравствуйте код в файле php вызывает ошибку на сайте, подскажите пожалуйста я правильно пишу путь : if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/ajax/index', $data)) { $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/ajax/index', $data)); } else { $this->response->setOutput($this->load->view('default/template/ajax/index', $data)); }
  15. Может кому-то пригодится. Я сумел вывести опции товаров в Opencart 3 следующим способом: ----------------------------------------------------------------------------------------------------- 1. В файле: catalog/controller/product/category.php Перед $data['products'][] = array( Вставить $options = array(); foreach ($this->model_catalog_product->getProductOptions($result['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $result['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'quantity' => $option_value['quantity'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $options[] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } 2. Добавить в массив $data['products'][] = array( новое значение (к примеру, после 'name' => $result['name'],), 'options' => $options, 3. В файле: catalog/view/theme/default/template/product/category.twig Найти: <div class="product-thumb"> И заменить на: <div class="product-thumb" id="product_{{ product.product_id }}"> 4. В том же файле (catalog/view/theme/default/template/product/category.twig). В нужное место вывести, но обязательно внутри - <div class="product-thumb" id="product_{{ product.product_id }}"> <!-- Выбор опций --> {% if product.options %} <hr> <h3>{{ text_option }}</h3> {% for option in product.options %} {% if option.type == 'select' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control"> <option value="">{{ text_select }}</option> {% for option_value in option.product_option_value %} <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </option> {% endfor %} </select> </div> {% endif %} {% if option.type == 'radio' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="radio"> <label> <input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% if option.type == 'checkbox' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="checkbox"> <label> <input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% endfor %} {% endif %} <!-- Конец выбора опций --> 4.1. В том же файле (catalog/view/theme/default/template/product/category.twig) Находим onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');" И заменяем на onclick="cart.add2('{{ product.product_id }}', '{{ product.minimum }}');" 5. Дальше лезем в скрипт: catalog/view/javascript/common.js Находим строку: 'update': function(key, quantity) { И перед ею добавляем : 'add2': function(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: $('#product_'+product_id+' input[type=\'text\'], #product_'+product_id+' input[type=\'hidden\'], #product_'+product_id+' input[type=\'radio\']:checked, #product_'+product_id+' input[type=\'checkbox\']:checked, #product_'+product_id+' select, #product_'+product_id+' textarea'), dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); if (json['redirect']) { location = json['redirect']; } if (json['success']) { $('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>'); // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); $('html, body').animate({ scrollTop: 0 }, 'slow'); $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); },
  16. Спасибо, вы в любом случае помогли. Решено было по-другому
  17. Выбило ошибку при добавлении в корзину (скрин 1) После появилась ошибка в скрипте (скрин 2). Второй раз попробовал добавить в корзину и ошибок больше не было, а опять начало переходить на страницу товара
  18. На Opencart 3 сайт. Да я обернул весь блок товара. Возможно проблема в кнопке добавить в корзину еще ? <button type="button" class="cart-buttons" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');">{{ button_cart }}</button>
  19. Я не совсем понял как именно мне сам js изменить. Скрипт в стандартном шаблоне выглядит так: var cart = { 'add': function(product_id, quantity) { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); if (json['redirect']) { location = json['redirect']; } if (json['success']) { $('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>'); // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); $('html, body').animate({ scrollTop: 0 }, 'slow'); $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }, 'update': function(key, quantity) { $.ajax({ url: 'index.php?route=checkout/cart/edit', type: 'post', data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { location = 'index.php?route=checkout/cart'; } else { $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }, 'remove': function(key) { $.ajax({ url: 'index.php?route=checkout/cart/remove', type: 'post', data: 'key=' + key, dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { location = 'index.php?route=checkout/cart'; } else { $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } } Я попробовал изменить как вы написали (возможно не правильно), так как ничего не изменилось и при выборе опции перекидывает на страницу товара.Сейчас скрипт выглядит так : var cart = { 'add': function(product_id, quantity) { var options = $('#option_product_' + product_id + ' input[type=\'radio\']:checked, #option_product_' + product_id + ' input[type=\'checkbox\']:checked, #option_' + product_id + ' select'); var data = options.serialize() + '&product_id=' + product_id + '&quantity=' + (typeof (quant) != 'undefined' ? quant : 1); $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: data, dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { $('.alert-dismissible, .text-danger').remove(); if (json['redirect']) { location = json['redirect']; } if (json['success']) { $('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>'); // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); $('html, body').animate({ scrollTop: 0 }, 'slow'); $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }, 'update': function(key, quantity) { $.ajax({ url: 'index.php?route=checkout/cart/edit', type: 'post', data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { location = 'index.php?route=checkout/cart'; } else { $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }, 'remove': function(key) { $.ajax({ url: 'index.php?route=checkout/cart/remove', type: 'post', data: 'key=' + key, dataType: 'json', beforeSend: function() { $('#cart > button').button('loading'); }, complete: function() { $('#cart > button').button('reset'); }, success: function(json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); }, 100); if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { location = 'index.php?route=checkout/cart'; } else { $('#cart > ul').load('index.php?route=common/cart/info ul li'); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }
  20. К сожалению я в Javascript не силен. Помогите пожалуйста, если знаете как сделать на ajax
  21. Здравствуйте, как мне сделать, чтобы при выборе опции товара в каталоге, товар добавлялся в корзину, а не переходил на страницу товара? вывел опции в каталоге товаров в файле catalog.php $options = array(); foreach ($this->model_catalog_product->getProductOptions($result['product_id']) as $option) { if($option['required']){ $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $result['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $options[] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } } В файле catalog.twig {% if product.options %} <hr> <h3>{{ text_option }}</h3> {% for option in product.options %} {% if option.type == 'select' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control"> <option value="">{{ text_select }}</option> {% for option_value in option.product_option_value %} <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </option> {% endfor %} </select> </div> {% endif %} {% if option.type == 'radio' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="radio"> <label> <input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% if option.type == 'checkbox' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %} <div class="checkbox"> <label> <input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" /> {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %} {{ option_value.name }} {% if option_value.price %} ({{ option_value.price_prefix }}{{ option_value.price }}) {% endif %} </label> </div> {% endfor %} </div> </div> {% endif %} {% if option.type == 'text' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control" /> </div> {% endif %} {% if option.type == 'textarea' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <textarea name="option[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control">{{ option.value }}</textarea> </div> {% endif %} {% if option.type == 'file' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label">{{ option.name }}</label> <button type="button" id="button-upload{{ option.product_option_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i class="fa fa-upload"></i> {{ button_upload }}</button> <input type="hidden" name="option[{{ option.product_option_id }}]" value="" id="input-option{{ option.product_option_id }}" /> </div> {% endif %} {% if option.type == 'date' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group date"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% if option.type == 'datetime' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group datetime"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% if option.type == 'time' %} <div class="form-group{% if option.required %} required {% endif %}"> <label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label> <div class="input-group time"> <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" /> <span class="input-group-btn"> <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> </span></div> </div> {% endif %} {% endfor %} {% endif %}
  22. Решение точно такое же как и на opencart 2. Правильный перевод в twig и все супер. Решение: 1. В файле /catalog/model/account/wishlist.php -после строк: " public function getTotalWishlist() { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "'"); return $query->row['total']; }" добавить: public function getAllWishlist() { if ($data = $this->getWishlist()) { $out = array(); foreach ($data as $key => $value) { $out[] = $value['product_id']; } return $out; } else if (isset($this->session->data['wishlist'])) { return $this->session->data['wishlist']; } } 2. В файле catalog\view\theme\default\template\product\category.twig Вместо кнопки "В закладки": <button type="button" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product.product_id }}');"><i class="fa fa-heart"></i></button> Вставьте: <button {% if (AllWishlist is defined) %} {% if (product['product_id'] in AllWishlist) %} style="color: red" {% endif %} {% endif %} type="button" class="wishlist-buttons" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product.product_id }}'); ChangeColor(this);"><i class="fa fa-star"></i></button> <script type="text/javascript"> function ChangeColor(Element) { Element.style.color = 'red'; } </script> 3. В файле catalog\controller\product\category.php Перед: $data['breadcrumbs'] = array(); Вставьте: $this->load->model('account/wishlist'); $data['AllWishlist'] = $this->model_account_wishlist->getAllWishlist(); 4. В файле catalog\controller\product\product.php Перед: if ($product_info) { $url = ''; Вставьте: $this->load->model('account/wishlist'); $zol_wish = $this->model_account_wishlist->getAllWishlist(); if (isset($product_id) && isset($zol_wish)) { if (in_array($product_id, $zol_wish)) { $data['AllWishlist'] = true; } } 5. В файле catalog\view\theme\default\template\product\product.twig Вместо: <button type="button" data-toggle="tooltip" class="btn btn-default" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product_id }}');"><i class="fa fa-heart"></i></button> Вставьте: <button {% if (AllWishlist is defined) %} style="color: red" {% endif %} type="button" class="btn btn-default" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product_id }}'); ChangeColor(this);"><i class="fa fa-heart"></i></button> <script type="text/javascript"> function ChangeColor(Element) { Element.style.color = 'red'; } </script>
  23. Здравствуйте, помогите сделать, чтобы стиль кнопки менялся при добавлении товара в избранные и сохранялся при обновлении страницы. Нужно решение для Opencart 3 Нашел на форуме тему, но там в tpl, я попробовал перевести в twig, но ничего не вышло Содержание решения с темы по Opencart 2 catalog\model\account\wishlist.php public function getAllWishlist() { if ($data = $this->getWishlist()) { $out = array(); foreach ($data as $key => $value) { $out[] = $value['product_id']; } return $out; } else if (isset($this->session->data['wishlist'])) { return $this->session->data['wishlist']; } } catalog\view\theme\default\template\product\category.tpl вместо: <button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button> это: <button <?php if(isset($AllWishlist)) { ?> <?php if(in_array($product['product_id'], $AllWishlist)) { ?> style="color: red" <?php } ?> <?php } ?> type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>'); ChangeColor(this);"><i class="fa fa-heart"></i></button> <script type="text/javascript"> function ChangeColor(Element) { Element.style.color = 'red'; } </script> catalog\controller\product\category.php перед $data['breadcrumbs'] = array(); это: $this->load->model('account/wishlist'); $data['AllWishlist'] = $this->model_account_wishlist->getAllWishlist(); catalog\controller\product\product.php перед if ($product_info) { $url = ''; это: $this->load->model('account/wishlist'); $zol_wish = $this->model_account_wishlist->getAllWishlist(); if (isset($product_id) && isset($zol_wish)) { if (in_array($product_id, $zol_wish)) { $data['AllWishlist'] = true; } } catalog\view\theme\default\template\product\product.tpl вместо: <button type="button" data-toggle="tooltip" class="btn btn-default" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product_id; ?>');"><i class="fa fa-heart"></i></button> это: <button <?php if(isset($AllWishlist)) { ?> style="color: red" <?php } ?> type="button" data-toggle="tooltip" class="btn btn-default" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product_id; ?>'); ChangeColor(this);"><i class="fa fa-heart"></i></button> <script type="text/javascript"> function ChangeColor(Element) { Element.style.color = 'red'; } </script>

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.