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

Функция update в корзине


 Share

Recommended Posts

Добрый гдень, подскажите пожалуйси не получается обновить значение поля когдачества в корзине на onkeyup

Код:

<i onclick="if($(this).next().val()> 1) cart.add('{{ product.product_id }}', -1);if($(this).next().val()>1) $(this).next().val($(this).next().val()-1);" class="fa fa-minus fa-minus-cart"></i>   
<input  type="text" name="quantity[{{ product.cart_id }}]" value="{{ product.quantity }}" size="1" class="form-control input-qty-cart" />                  
<i onclick="$(this).prev().val(~~$(this).prev().val()+1);cart.add('{{ product.product_id }}', 1);" class="fa fa-plus fa-plus-cart"></i></div>
       

По нажатию на + и - товар добавляется/удаляется.

Нужно чтобы еещё при ввогде в сам input происходило обновление товара в корзине. Добавляю onkeyup

Есть синдартная функция update, но  непонятно что туда надо передавать, чтобы обновлялось. И как полулить текуещёе значение в Input.

$(this).val() возвращает 0, а $(this).value значение, которое было перед изменением.

В update передавала и {{product.cart_id}} и {{product.product_id}}  с когдачеством, но ошибка.

Пропотому чтовала сгделать еещё просто через добавление          

cart.add('{{ product.product_id }}', -{{product.product_id}}+$(this).val());

Но $(this).val() возвращает 0

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.