Здравствуйте подскажите пожалуйста как правильно отослать ajax запрос в корзину. Суть в том:чтобы запросом из поля <input> передавалось количество товаров которые мы хотим купить.
Это часть шаблона корзины, где я хочу чтобы переменная $arBasketItems["QUANTITY"] получала мой запрос.
Буду рад любой помощи, спасибо.
Код |
---|
Т.к происходит отправка с помощью $arElement["ADD_URL"] , то поле с количеством не отправляется. <div class="text_input" > <div class="text_input_wrap"> <input class="category_count_input" name="<?echo $arParams["PRODUCT_QUANTITY_VARIABLE"]?>" value="1" type="text"/> </div> </div> <div class="link_wrapper_blocker"> <a class="category_count_button count_button_b open_popup" href="<?=$arElement["ADD_URL"]?>" rel="popup1" id="<?=$arElement["ID"]?>">КУПИТЬ</a> </div> |
Код |
---|
$(".category_count_button").on("click",function(){ var ok = $(this).parent().prev().children().children().val();//Идея не моя console.log(ok); //Количество товаров $.ajax({ type: 'POST', url: '/personal/cart/index.php', //Здесь вызов корзины. data: {quantity:ok}, success: function(data) { } }); }); }); Вот такой вызов $APPLICATION->IncludeComponent("custom:sale.basket.order","",Array( "ORDER_ID" => $_REQUEST["ORDER_ID"] ) ); |
Код |
---|
<?foreach($arResult["ITEMS"]["AnDelCanBuy"] as $arBasketItems):?> <? $props = array(); foreach ($arBasketItems["PROPS"] as $prop) { $props[$prop["CODE"]] = $prop; } $arBasketItems["PROPS"] = $props; $totalValue += doubleval($arBasketItems["PROPS"]["VOLUME"]["VALUE"]) * $arBasketItems["QUANTITY"]; ?> <tr> <td> <a href="<?=$arBasketItems['~DETAIL_PAGE_URL']?>"><?=$arBasketItems['NAME']?></a> </td> <td> <?=$arBasketItems["PROPS"]["IN_PACK"]["VALUE"]?> </td> <?if (!$arResult["PRICES_HIDE"]&& $USER->IsAuthorized()):?> <td> <?=$arBasketItems["PRICE"]?> </td> <?endif;?> <td> <div class="cart_input_wrap"> <div class="text_input"> <div class="text_input_wrap"> <input maxlength="18" class="cart_count_input" type="text" name="QUANTITY_<?=$arBasketItems["ID"]?>" value="<?=intval($arBasketItems["QUANTITY"])?>" size="3" > </div> </div> </div> </td> <?if (!$arResult["PRICES_HIDE"] && $USER->IsAuthorized()):?> <td> <span class="cart_total_due"> <?=intval($arBasketItems["PRICE"] * $arBasketItems["QUANTITY"]);?> </span> </td> <?endif;?> <td> <input type="checkbox" name="DELETE_<?=$arBasketItems["ID"] ?>" id="DELETE_<?=$i?>" value="Y"> </td> </tr> <?endforeach?> |