Answer the question
In order to leave comments, you need to log in
How to change the number of items in the Bitrix cart?
There are items in the cart. Removing them from the cart is implemented, but changing the number of products cannot be done. I change using
By analogy with deletion, using the default template as an example, I tracked where requests go when the quantity in the field changes.
Requests go to:
1. /bitrix/components/bitrix/sale.basket.basket/ajax.php
2. /bitrix/components/bitrix/sale.basket.basket.line/ajax.php
3. /bitrix/components/bitrix /sale.products.gift.basket/ajax.php
4. /bitrix/components/bitrix/sale.products.gift.basket/ajax.php
4 requests in total. The second one changes the number of elements in the cart icon
. The first one goes to the script that processes the calculation of the amount and returns the changed values. 3 and 4 - I do not touch requests.<input type="number">
As a result, I send one request to the first address from the list with Ajax.
Json is returned, but the number in it is not changed
Ajax script:
$(document).on('click','#cart_to_quantity',function(){
$.ajax({
url: '/bitrix/components/bitrix/sale.basket.basket/ajax.php',
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function (result) {
console.log(result);
BX.onCustomEvent('OnBasketChange');
}
});
return false;
});
<form id="cart_to_quantity">
<input class="clic_item" type="number" name="basket[QUANTITY__<?=$item['ID']?>]" value="<?=$item['QUANTITY']?>">
<input type="hidden" name="basketAction" value="recalculateAjax"
<input type="hidden" name="site_template_id" value=" bertonv">
<input type="hidden" name="site_id" value="s1">
<input type="hidden" name="sessid" value="<?=$my_func?>">
</form>
<input type="number">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question