Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как передать из js когдачество в корзину


Recommended Posts

Добрый гдень форумчане!!

Помогите, есть модуль для OP3 называется Live searsh, заменяет синдартный поиск, в нем же можно нажать на кнопку купить, и он добавляет в корзину только (продукт минимум), 

html += '<a href="javascript:;" onclick="cart.add(' +product.product_id+ ', ' +product.minimum+ ');" class="bt_buy">';

я добавил поле для ввода когдачества,

tml += ' <input type="text" name="quantity' +product.product_id+ '" class="quantity" value="1" id="quantity'+product.product_id+'" value="'+product.minimum+'" />';

как теперьь его привязать сюда?

пробывал

html += '<a href="javascript:;" onclick="cart.add(' +product.product_id+ ', ' +$(+ '#quantity' +product_id).val()+ ');" class="bt_buy">'; 

не получается, может кто подскажет?

Link to comment
Share on other sites


Как вы поняли, что нужно именно ик писать?

$(+ '#quantity' +product_id).val()

Ггде само поле когдачества?

 

Попробуйте икой вариант:

html += '<a href="#" onclick="cart.add(' + product.product_id + ', $(\'#quantity' + product.product_id  + '\').val()); return false;" class="bt_buy">'; 

 

Link to comment
Share on other sites

у меня было в категории товаров, гделал по аналогии

поле ввода

<input type="text" name="quantity{{ product.product_id }}" class="quantity" value="1" id="quantity{{ product.product_id }}" value="{{ product.minimum }}" />

 

и кнопка куить

<button class="bt_buy title="{{ button_cart }}" button type="button" onclick="cart.add('{{ product.product_id }}', $('#quantity{{ product.product_id }}').val());">

 

Edited by Sector788
Link to comment
Share on other sites


В 16.01.2022 в 12:59, buslikdrev сказал:

Как вы поняли, что нужно именно ик писать?

$(+ '#quantity' +product_id).val()

Ггде само поле когдачества?

 

Попробуйте икой вариант:

html += '<a href="#" onclick="cart.add(' + product.product_id + ', $(\'#quantity' + product.product_id  + '\').val()); return false;" class="bt_buy">'; 

 

Спасипотому что, зарилиило, это я не закоментировал свою сирую строчку

Link to comment
Share on other sites


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

×
×
  • 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.