A
A
Anumik2016-08-10 09:47:36
1C-Bitrix
Anumik, 2016-08-10 09:47:36

Why is the number of items in the cart not being transferred?

Good day!
In the catalog.section component, a form for changing the quantity of goods, but the value was not transmitted by standard Bitrix tools. Useful to understand, googled, tried everything I found, but does not work. As a result, I came to a script that passes /catalog/?action=ADD2BASKET&id=391&quantity=5 (?action=ADD2BASKET&id=391 from the $arItemIDs['BUY_LINK'] variable, the quantity variable is set and written correctly, jquery is pulled from the input), but why then the value 2 is always transmitted, I can’t understand why this can be so?
Script

$('.bx_bt_button.bx_medium').on('click',function(e){

            if(!$(this).hasClass('success-btn')){
              e.preventDefault();
              $(this).addClass('success-btn');
              $(this).text('В корзине');
              var quantity = "&quantity=" + $(this).parents(".catalog_item_buy").find('input[name="quantity"]').val();
              var url = $(this).attr('href') + quantity;
              console.log(url);
              $.ajax({
              type:'POST',
              beforeSend:function(){
                BX.showWait();
              },
              url:url,
              success:function(data){
                BX.onCustomEvent('OnBasketChange');
                $('.bx_big.bx_bt_button.bx_cart').attr({'href':'/personal/cart/'});

                BX.closeWait();
              },

            })
          }


      })

Standard JS did not touch

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Harakhnin, 2016-08-10
@Chupokabr

Firstly, the component has a checkbox associated with the ability to select the quantity of goods (such as transfer quantity or allow quantity selection).
Further on the script. If you have altered the layout, then check the classes. The number is obtained by selectors. First, the parent element with the class ".catalog_item_buy" is searched, the stream in it is a field with the name 'input[name="quantity"]' and the value of the quantity is taken.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question