Kitson Posted June 30, 2012 Share Posted June 30, 2012 Разработчик: http://darrennolan.c...-category-page/ Работает на версии: 1.5.3.1 Как перенести данный модуль на 1.5.1.3 ? Сейчас данный модуль на версии 1.5.1.3 добавляет товары в корзину, но не берёт во внимание указанное количество, то есть если ввести количество пять он всё равно добавляет в корзину только одну штуку. Как поправить код? Установка на русском: Открываем /catalog/view/theme/default/template/product/category.tpl Найти: <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" /> Заменить на: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Найти ниже: <script type="text/javascript"><!-- Вставить после: function addQtyToCart(product_id) { var qty = $('.item-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } addToCart(product_id, qty); } Link to comment Share on other sites More sharing options...
ravilr Posted June 30, 2012 Share Posted June 30, 2012 видимо еще в common.js надо изменения внести для функции addToCart... типа таких function addToCart(product_id,quantity) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id='+ product_id , 'quantity='+ quantity , 1 Link to comment Share on other sites More sharing options... Kitson Posted June 30, 2012 Author Share Posted June 30, 2012 Всё разобрался. Спасибо ravilr за наводку. Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, 1 Link to comment Share on other sites More sharing options... vikvid Posted June 30, 2012 Share Posted June 30, 2012 Спасибо, чудесное решение. Link to comment Share on other sites More sharing options... Kitson Posted July 1, 2012 Author Share Posted July 1, 2012 Теперь хочу сделать выбор количества из всплывающего окна. Можно ли это сделать? <div class="cart"> <script type="text/javascript"><!-- $('.cart div:nth-child(3) a').click(function(){ $('#popup-options').slideUp(); $('#modal-overlay').fadeOut(); }); --></script> <div id="modal-overlay" onclick="$('#modal-overlay').fadeOut(); $('#popup-options').slideUp()"></div> <a class="button" style="margin-bottom: 10px" onclick="$('#modal-overlay').fadeIn(); $('#popup-options').slideDown();"> <span>Выбор количества</span> </a> <div id="popup-options"> <input type="text" value="1" SIZE="2" class="item-<?php echo $product['product_id']; ?>" /> <a class="button" style="margin-bottom: 10px" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"> <span>Купить</span> </a> </div> </div> При таком коде, нажимая на кнопку купить во всплывающем окне в корзину всегда добавляется первый в списке товар (не важно рядом с каким товаром нажмешь на выбор количества). Как сделать так, чтобы добавлялся тот товар рядом с которым нажимаешь на выбор количества? Код стилей не стал сюда копировать - не принципиально. Link to comment Share on other sites More sharing options... 1 month later... Baco Posted August 6, 2012 Share Posted August 6, 2012 Всё разобрался. Спасибо ravilr за наводку. Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, Отличное решение, но есть одна маленькая загвоздка, если добавления товаров происходят, и кешируються в папке sys то в итоге, какое кол-во товаров не выбирать, всёравно добавляется в корзину кол-во равное 1, есть идеи ? 1 Link to comment Share on other sites More sharing options... Kitson Posted August 8, 2012 Author Share Posted August 8, 2012 Отличное решение, но есть одна маленькая загвоздка, если добавления товаров происходят, и кешируються в папке sys то в итоге, какое кол-во товаров не выбирать, всёравно добавляется в корзину кол-во равное 1, есть идеи ?А изменения, которые я описал в начале темы вы сделали?Правильно устанавливать так: Открываем /catalog/view/theme/default/template/product/category.tpl Найти: <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" /> Заменить на: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Найти ниже: <script type="text/javascript"><!-- Вставить после: function addQtyToCart(product_id) { var qty = $('.item-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } addToCart(product_id, qty); } Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, Link to comment Share on other sites More sharing options... 5 months later... loveinn Posted January 31, 2013 Share Posted January 31, 2013 Хочу тоже вставить возможность выбора количества товара, но у меня не дефолтная тема (1.5.3.1). Помогите подружить код с уже имеющимся. Тот что есть в темплейте: <div class="cart"> <a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div и этот нужно добавить: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /><input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Link to comment Share on other sites More sharing options... loveinn Posted February 1, 2013 Share Posted February 1, 2013 Сама разобралась, вот что в конечном итоге вышло: <div class="cart"> <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <a onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div> Link to comment Share on other sites More sharing options... 1 month later... ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 Есть решение попроще... catalog/controller/product/category.php - после - 'product_id' => $result['product_id'], Вставляем - 'minimum' => $result['minimum'], catalog/view/theme/default/template/product/category.tpl - в <div class="cart"> вставляем следующий код <div> <input type="text" name="quantity" size="2" value="<?php echo $product['minimum']; ?>" id="quantity_<?php echo $product['product_id']; ?>"/> <input type="hidden" name="product_id" size="2" value="<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>',document.getElementById('quantity_<?php echo $product['product_id']; ?>').value);" class="button" /> </div> 2 Link to comment Share on other sites More sharing options... ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( Link to comment Share on other sites More sharing options... 3 weeks later... fox9595 Posted March 27, 2013 Share Posted March 27, 2013 мне на opencart 1/5/3/1 не подошел не один из выше описанных методов Link to comment Share on other sites More sharing options... 3 months later... Saimon Posted July 22, 2013 Share Posted July 22, 2013 Поставил метод в первом посте на 1.5.4.1 - работает Link to comment Share on other sites More sharing options... 3 weeks later... Puchkof Posted August 6, 2013 Share Posted August 6, 2013 Есть решение попроще... и правильнее <?php echo $product['minimum']; ?> позволяет добавлять правильное минимальное количество для данного товара, установленное в карточке товара, если оно отлично от единицы. проверено на 1.5.4.1 Link to comment Share on other sites More sharing options... 5 months later... castlebor Posted January 22, 2014 Share Posted January 22, 2014 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( подскажите пожалуйста, как приделать кнопочки + и - 1 Link to comment Share on other sites More sharing options... 8 months later... tigra1986 Posted October 3, 2014 Share Posted October 3, 2014 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Link to comment Share on other sites More sharing options... 3 weeks later... Stealth421 Posted October 23, 2014 Share Posted October 23, 2014 на 1.5.6.4. добавляет только 1 товар ( Link to comment Share on other sites More sharing options... 6 months later... arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options... arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options... 4 months later... webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options... 5 months later... specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options... 1 month later... Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options... Create an account or sign in to comment You need to be a member in order to leave a comment Create an account Sign up for a new account in our community. It's easy! Register a new account Sign in Already have an account? Sign in here. Sign In Now Share More sharing options... Followers 0 Go to topic listing Similar Content количество комментариев на странице товара By AlexMax13, January 10 2 replies 92 views AlexMax13 January 10 Продукты списком в категории By foggy, January 24 3 replies 118 views spectre January 24 Отображение количества заказов одного клиента в списке заказов By Sumsee, Yesterday at 08:06 AM 1 reply 87 views Agatha65 22 hours ago Количество акционного товара By Seofisher, January 10, 2022 1 reply 272 views Verzun Monday at 03:17 PM Изменить количество всех товаров By wizand1, March 15, 2018 5 replies 890 views nikoshot January 17 Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Поддержка и ответы на вопросы Модули и дополнения Вывод товара, изображения, фильтры вывода Модуль добавляет возможность выбора количества товара из списка товаров (страница категории) Покупателям Оплата дополнений физическими лицами Оплата дополнений юридическими лицами Политика возвратов Разработчикам Регламент размещения дополнений Регламент продаж и поддержки дополнений Виртуальный аккаунт автора Политика продвижения объявлений API каталога дополнений Урегулирование споров по авторским правам Полезная информация Публичная оферта Политика возвратов Политика конфиденциальности Платежная политика Политика Передачи Персональных Данных Политика прозрачности Последние дополнения Chameleon - Responsive & Multipurpose Opencart Template + Quick Start By 29aleksey Wayforpay API оплата для Opencart 2.3, 3.x By bogdan281989 TgMarket - Модуль интернет магазина в телеграмме. By Rassol2 ShowCase – Responsive / Multipurpose Opencart Template By octemplates Telnotification By Yevhenii_7777 × Existing user? Sign In Sign Up Shopping section Back Purchased extensions Invoices Whishlist Alternative Contacts Forums News ocStore Back Official site Demo ocStore 3.0.3.2 Demo ocStore 2.3.0.2.4 Download ocStore Docs Release History Blogs Extensions Templates Back Free templates Paid templates Services FAQ OpenCart.Pro Back Demo Buy Compare × Create New... Important Information On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice. I accept
Kitson Posted June 30, 2012 Author Share Posted June 30, 2012 Всё разобрался. Спасибо ravilr за наводку. Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, 1 Link to comment Share on other sites More sharing options...
vikvid Posted June 30, 2012 Share Posted June 30, 2012 Спасибо, чудесное решение. Link to comment Share on other sites More sharing options...
Kitson Posted July 1, 2012 Author Share Posted July 1, 2012 Теперь хочу сделать выбор количества из всплывающего окна. Можно ли это сделать? <div class="cart"> <script type="text/javascript"><!-- $('.cart div:nth-child(3) a').click(function(){ $('#popup-options').slideUp(); $('#modal-overlay').fadeOut(); }); --></script> <div id="modal-overlay" onclick="$('#modal-overlay').fadeOut(); $('#popup-options').slideUp()"></div> <a class="button" style="margin-bottom: 10px" onclick="$('#modal-overlay').fadeIn(); $('#popup-options').slideDown();"> <span>Выбор количества</span> </a> <div id="popup-options"> <input type="text" value="1" SIZE="2" class="item-<?php echo $product['product_id']; ?>" /> <a class="button" style="margin-bottom: 10px" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"> <span>Купить</span> </a> </div> </div> При таком коде, нажимая на кнопку купить во всплывающем окне в корзину всегда добавляется первый в списке товар (не важно рядом с каким товаром нажмешь на выбор количества). Как сделать так, чтобы добавлялся тот товар рядом с которым нажимаешь на выбор количества? Код стилей не стал сюда копировать - не принципиально. Link to comment Share on other sites More sharing options...
Baco Posted August 6, 2012 Share Posted August 6, 2012 Всё разобрался. Спасибо ravilr за наводку. Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, Отличное решение, но есть одна маленькая загвоздка, если добавления товаров происходят, и кешируються в папке sys то в итоге, какое кол-во товаров не выбирать, всёравно добавляется в корзину кол-во равное 1, есть идеи ? 1 Link to comment Share on other sites More sharing options... Kitson Posted August 8, 2012 Author Share Posted August 8, 2012 Отличное решение, но есть одна маленькая загвоздка, если добавления товаров происходят, и кешируються в папке sys то в итоге, какое кол-во товаров не выбирать, всёравно добавляется в корзину кол-во равное 1, есть идеи ?А изменения, которые я описал в начале темы вы сделали?Правильно устанавливать так: Открываем /catalog/view/theme/default/template/product/category.tpl Найти: <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" /> Заменить на: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Найти ниже: <script type="text/javascript"><!-- Вставить после: function addQtyToCart(product_id) { var qty = $('.item-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } addToCart(product_id, qty); } Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, Link to comment Share on other sites More sharing options... 5 months later... loveinn Posted January 31, 2013 Share Posted January 31, 2013 Хочу тоже вставить возможность выбора количества товара, но у меня не дефолтная тема (1.5.3.1). Помогите подружить код с уже имеющимся. Тот что есть в темплейте: <div class="cart"> <a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div и этот нужно добавить: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /><input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Link to comment Share on other sites More sharing options... loveinn Posted February 1, 2013 Share Posted February 1, 2013 Сама разобралась, вот что в конечном итоге вышло: <div class="cart"> <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <a onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div> Link to comment Share on other sites More sharing options... 1 month later... ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 Есть решение попроще... catalog/controller/product/category.php - после - 'product_id' => $result['product_id'], Вставляем - 'minimum' => $result['minimum'], catalog/view/theme/default/template/product/category.tpl - в <div class="cart"> вставляем следующий код <div> <input type="text" name="quantity" size="2" value="<?php echo $product['minimum']; ?>" id="quantity_<?php echo $product['product_id']; ?>"/> <input type="hidden" name="product_id" size="2" value="<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>',document.getElementById('quantity_<?php echo $product['product_id']; ?>').value);" class="button" /> </div> 2 Link to comment Share on other sites More sharing options... ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( Link to comment Share on other sites More sharing options... 3 weeks later... fox9595 Posted March 27, 2013 Share Posted March 27, 2013 мне на opencart 1/5/3/1 не подошел не один из выше описанных методов Link to comment Share on other sites More sharing options... 3 months later... Saimon Posted July 22, 2013 Share Posted July 22, 2013 Поставил метод в первом посте на 1.5.4.1 - работает Link to comment Share on other sites More sharing options... 3 weeks later... Puchkof Posted August 6, 2013 Share Posted August 6, 2013 Есть решение попроще... и правильнее <?php echo $product['minimum']; ?> позволяет добавлять правильное минимальное количество для данного товара, установленное в карточке товара, если оно отлично от единицы. проверено на 1.5.4.1 Link to comment Share on other sites More sharing options... 5 months later... castlebor Posted January 22, 2014 Share Posted January 22, 2014 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( подскажите пожалуйста, как приделать кнопочки + и - 1 Link to comment Share on other sites More sharing options... 8 months later... tigra1986 Posted October 3, 2014 Share Posted October 3, 2014 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Link to comment Share on other sites More sharing options... 3 weeks later... Stealth421 Posted October 23, 2014 Share Posted October 23, 2014 на 1.5.6.4. добавляет только 1 товар ( Link to comment Share on other sites More sharing options... 6 months later... arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options... arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options... 4 months later... webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options... 5 months later... specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options... 1 month later... Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options... Create an account or sign in to comment You need to be a member in order to leave a comment Create an account Sign up for a new account in our community. It's easy! Register a new account Sign in Already have an account? Sign in here. Sign In Now Share More sharing options... Followers 0 Go to topic listing Similar Content количество комментариев на странице товара By AlexMax13, January 10 2 replies 92 views AlexMax13 January 10 Продукты списком в категории By foggy, January 24 3 replies 118 views spectre January 24 Отображение количества заказов одного клиента в списке заказов By Sumsee, Yesterday at 08:06 AM 1 reply 87 views Agatha65 22 hours ago Количество акционного товара By Seofisher, January 10, 2022 1 reply 272 views Verzun Monday at 03:17 PM Изменить количество всех товаров By wizand1, March 15, 2018 5 replies 890 views nikoshot January 17 Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Поддержка и ответы на вопросы Модули и дополнения Вывод товара, изображения, фильтры вывода Модуль добавляет возможность выбора количества товара из списка товаров (страница категории) Покупателям Оплата дополнений физическими лицами Оплата дополнений юридическими лицами Политика возвратов Разработчикам Регламент размещения дополнений Регламент продаж и поддержки дополнений Виртуальный аккаунт автора Политика продвижения объявлений API каталога дополнений Урегулирование споров по авторским правам Полезная информация Публичная оферта Политика возвратов Политика конфиденциальности Платежная политика Политика Передачи Персональных Данных Политика прозрачности Последние дополнения Chameleon - Responsive & Multipurpose Opencart Template + Quick Start By 29aleksey Wayforpay API оплата для Opencart 2.3, 3.x By bogdan281989 TgMarket - Модуль интернет магазина в телеграмме. By Rassol2 ShowCase – Responsive / Multipurpose Opencart Template By octemplates Telnotification By Yevhenii_7777
Kitson Posted August 8, 2012 Author Share Posted August 8, 2012 Отличное решение, но есть одна маленькая загвоздка, если добавления товаров происходят, и кешируються в папке sys то в итоге, какое кол-во товаров не выбирать, всёравно добавляется в корзину кол-во равное 1, есть идеи ?А изменения, которые я описал в начале темы вы сделали?Правильно устанавливать так: Открываем /catalog/view/theme/default/template/product/category.tpl Найти: <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" /> Заменить на: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Найти ниже: <script type="text/javascript"><!-- Вставить после: function addQtyToCart(product_id) { var qty = $('.item-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } addToCart(product_id, qty); } Меняем в catalog/view/javascript/common.js function addToCart(product_id) { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id, на function addToCart(product_id, quantity) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, Link to comment Share on other sites More sharing options...
loveinn Posted January 31, 2013 Share Posted January 31, 2013 Хочу тоже вставить возможность выбора количества товара, но у меня не дефолтная тема (1.5.3.1). Помогите подружить код с уже имеющимся. Тот что есть в темплейте: <div class="cart"> <a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div и этот нужно добавить: <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /><input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button" /> Link to comment Share on other sites More sharing options...
loveinn Posted February 1, 2013 Share Posted February 1, 2013 Сама разобралась, вот что в конечном итоге вышло: <div class="cart"> <input type="text" value="1" class="item-<?php echo $product['product_id']; ?>" /> <a onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="button addToCart"><span><?php echo $button_cart; ?></span></a></div> Link to comment Share on other sites More sharing options...
ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 Есть решение попроще... catalog/controller/product/category.php - после - 'product_id' => $result['product_id'], Вставляем - 'minimum' => $result['minimum'], catalog/view/theme/default/template/product/category.tpl - в <div class="cart"> вставляем следующий код <div> <input type="text" name="quantity" size="2" value="<?php echo $product['minimum']; ?>" id="quantity_<?php echo $product['product_id']; ?>"/> <input type="hidden" name="product_id" size="2" value="<?php echo $product['product_id']; ?>" /> <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>',document.getElementById('quantity_<?php echo $product['product_id']; ?>').value);" class="button" /> </div> 2 Link to comment Share on other sites More sharing options... ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( Link to comment Share on other sites More sharing options... 3 weeks later... fox9595 Posted March 27, 2013 Share Posted March 27, 2013 мне на opencart 1/5/3/1 не подошел не один из выше описанных методов Link to comment Share on other sites More sharing options... 3 months later... Saimon Posted July 22, 2013 Share Posted July 22, 2013 Поставил метод в первом посте на 1.5.4.1 - работает Link to comment Share on other sites More sharing options... 3 weeks later... Puchkof Posted August 6, 2013 Share Posted August 6, 2013 Есть решение попроще... и правильнее <?php echo $product['minimum']; ?> позволяет добавлять правильное минимальное количество для данного товара, установленное в карточке товара, если оно отлично от единицы. проверено на 1.5.4.1 Link to comment Share on other sites More sharing options... 5 months later... castlebor Posted January 22, 2014 Share Posted January 22, 2014 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( подскажите пожалуйста, как приделать кнопочки + и - 1 Link to comment Share on other sites More sharing options... 8 months later... tigra1986 Posted October 3, 2014 Share Posted October 3, 2014 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Link to comment Share on other sites More sharing options... 3 weeks later... Stealth421 Posted October 23, 2014 Share Posted October 23, 2014 на 1.5.6.4. добавляет только 1 товар ( Link to comment Share on other sites More sharing options... 6 months later... arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options... arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options... 4 months later... webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options... 5 months later... specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options... 1 month later... Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options... Create an account or sign in to comment You need to be a member in order to leave a comment Create an account Sign up for a new account in our community. It's easy! Register a new account Sign in Already have an account? Sign in here. Sign In Now Share More sharing options... Followers 0 Go to topic listing Similar Content количество комментариев на странице товара By AlexMax13, January 10 2 replies 92 views AlexMax13 January 10 Продукты списком в категории By foggy, January 24 3 replies 118 views spectre January 24 Отображение количества заказов одного клиента в списке заказов By Sumsee, Yesterday at 08:06 AM 1 reply 87 views Agatha65 22 hours ago Количество акционного товара By Seofisher, January 10, 2022 1 reply 272 views Verzun Monday at 03:17 PM Изменить количество всех товаров By wizand1, March 15, 2018 5 replies 890 views nikoshot January 17 Recently Browsing 0 members No registered users viewing this page. Последние темы Последние дополнения Последние новости All Activity Home Поддержка и ответы на вопросы Модули и дополнения Вывод товара, изображения, фильтры вывода Модуль добавляет возможность выбора количества товара из списка товаров (страница категории)
ocdev_pro Posted March 9, 2013 Share Posted March 9, 2013 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( Link to comment Share on other sites More sharing options... 3 weeks later... fox9595 Posted March 27, 2013 Share Posted March 27, 2013 мне на opencart 1/5/3/1 не подошел не один из выше описанных методов Link to comment Share on other sites More sharing options... 3 months later... Saimon Posted July 22, 2013 Share Posted July 22, 2013 Поставил метод в первом посте на 1.5.4.1 - работает Link to comment Share on other sites More sharing options... 3 weeks later... Puchkof Posted August 6, 2013 Share Posted August 6, 2013 Есть решение попроще... и правильнее <?php echo $product['minimum']; ?> позволяет добавлять правильное минимальное количество для данного товара, установленное в карточке товара, если оно отлично от единицы. проверено на 1.5.4.1 Link to comment Share on other sites More sharing options... 5 months later... castlebor Posted January 22, 2014 Share Posted January 22, 2014 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( подскажите пожалуйста, как приделать кнопочки + и - 1 Link to comment Share on other sites More sharing options... 8 months later... tigra1986 Posted October 3, 2014 Share Posted October 3, 2014 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Link to comment Share on other sites More sharing options... 3 weeks later... Stealth421 Posted October 23, 2014 Share Posted October 23, 2014 на 1.5.6.4. добавляет только 1 товар ( Link to comment Share on other sites More sharing options... 6 months later... arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options... arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options... 4 months later... webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options... 5 months later... specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options... 1 month later... Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options... Create an account or sign in to comment You need to be a member in order to leave a comment Create an account Sign up for a new account in our community. It's easy! Register a new account Sign in Already have an account? Sign in here. Sign In Now Share More sharing options... Followers 0 Go to topic listing Similar Content количество комментариев на странице товара By AlexMax13, January 10 2 replies 92 views AlexMax13 January 10 Продукты списком в категории By foggy, January 24 3 replies 118 views spectre January 24 Отображение количества заказов одного клиента в списке заказов By Sumsee, Yesterday at 08:06 AM 1 reply 87 views Agatha65 22 hours ago Количество акционного товара By Seofisher, January 10, 2022 1 reply 272 views Verzun Monday at 03:17 PM Изменить количество всех товаров By wizand1, March 15, 2018 5 replies 890 views nikoshot January 17 Recently Browsing 0 members No registered users viewing this page.
fox9595 Posted March 27, 2013 Share Posted March 27, 2013 мне на opencart 1/5/3/1 не подошел не один из выше описанных методов Link to comment Share on other sites More sharing options...
Saimon Posted July 22, 2013 Share Posted July 22, 2013 Поставил метод в первом посте на 1.5.4.1 - работает Link to comment Share on other sites More sharing options...
Puchkof Posted August 6, 2013 Share Posted August 6, 2013 Есть решение попроще... и правильнее <?php echo $product['minimum']; ?> позволяет добавлять правильное минимальное количество для данного товара, установленное в карточке товара, если оно отлично от единицы. проверено на 1.5.4.1 Link to comment Share on other sites More sharing options...
castlebor Posted January 22, 2014 Share Posted January 22, 2014 А вот как кнопки + [ 1 ] - прикрутить на страницу списка категорий? сам ломал голову, получилось, но кнопки работают только значение количества не зависимо от нажатой кнопки изменяется только для первого товара((( подскажите пожалуйста, как приделать кнопочки + и - 1 Link to comment Share on other sites More sharing options...
tigra1986 Posted October 3, 2014 Share Posted October 3, 2014 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Link to comment Share on other sites More sharing options...
Stealth421 Posted October 23, 2014 Share Posted October 23, 2014 на 1.5.6.4. добавляет только 1 товар ( Link to comment Share on other sites More sharing options... 6 months later... arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options... arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options... 4 months later... webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options... 5 months later... specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options... 1 month later... Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options... Create an account or sign in to comment You need to be a member in order to leave a comment Create an account Sign up for a new account in our community. It's easy! Register a new account Sign in Already have an account? Sign in here. Sign In Now Share More sharing options... Followers 0
arshanskiyav Posted May 4, 2015 Share Posted May 4, 2015 Подскажите пожалуйста, как сделать тоже самое для версии opencart 2.0 (возможность выбора количества товара из списка товаров) Отличие в одном, в 2 функция называется cart.add, никаких изменений в common.js В моем варианте еще изменен поиск input, в оригинале он ориентируется на класс, у меня на ИД. <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /><button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> <script type="text/javascript"><!-- function addQtyToCart(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; } cart.add(product_id, qty); } --></script> А если нужен выбор, из выпадающего списка, тогда используйте: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> Link to comment Share on other sites More sharing options...
arshanskiyav Posted May 5, 2015 Share Posted May 5, 2015 подскажите пожалуйста, как приделать кнопочки + и - Я этот вопрос решил так: <button type="button" data-toggle="tooltip" onclick="EditMaxQuant('<?php echo $product['product_id']; ?>');" >+</button> <input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" /> <button type="button" data-toggle="tooltip" onclick="EditMinQuant('<?php echo $product['product_id']; ?>');" >-</button> <script type="text/javascript"><!-- function EditMinQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)-1; } $('#input-quantity-' + product_id).val(qty); } --> </script> <script type="text/javascript"><!-- function EditMaxQuant(product_id) { var qty = $('#input-quantity-' + product_id).val(); if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) { qty = 1; }else{ qty=Number(qty)+1; } $('#input-quantity-' + product_id).val(qty); } --> </script> Со стилями сами разберетесь, у меня кнопочки и поле ввода кол-ва зависит от вида отображения (сетка/список) 1 Link to comment Share on other sites More sharing options...
webprofiler Posted September 14, 2015 Share Posted September 14, 2015 у меня так не получается. может я чето не то делаю? Link to comment Share on other sites More sharing options...
specussa Posted March 8, 2016 Share Posted March 8, 2016 (edited) Я этот вопрос решил так... Спасибо огромнейшее, очень облегчил мне работу! Edited March 8, 2016 by specussa Link to comment Share on other sites More sharing options...
Dimansh Posted April 24, 2016 Share Posted April 24, 2016 (edited) а как перенести этот "модуль" в 2.1.0.2 ? Точнее: не пойму, как прикрутить выпадающий список, как в теме выше: <select> <option value="Sony">Sony</option> <option value="Toshiba">Toshiba</option> <option value="Acer">Acer</option> <option value="Asus">Asus</option> </select> У меня так: <button type="button" class="btn btn-default" onclick="cart.add('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></button> Edited April 24, 2016 by Dimansh Link to comment Share on other sites More sharing options...
Recommended Posts