D
D
Dmitry Zorin2019-11-11 22:36:09
1C-Bitrix
Dmitry Zorin, 2019-11-11 22:36:09

Bitrix "product in the cart" when adding, how to do?

Hello, such a question
In the bitrix of the small business edition, there is a button for adding an item to the cart (in the list of products)
When you click on the button, a modal window pops up with a notification that the item has been added to the cart
What I want to do is that when you click "add Add to Cart", the button changed to "In Cart"
Add product code:

<a class="btn btn-default to_basket <?=$buttonSizeClass?>" id="<?=$itemIds['BUY_LINK']?>"
href="javascript:void(0)" rel="nofollow">
<?=($arParams['ADD_TO_BASKET_ACTION'] === 'BUY' ? $arParams['MESS_BTN_BUY'] : $arParams['MESS_BTN_ADD_TO_BASKET'])?>
</a>

I added a script:
<script>
$(document).ready(function () {
    $('.to_basket').click(function () {
        $(this).addClass('in_basket'); 
        $(this).text("В корзине");
    });
});
</script>

When the button is pressed, it changes, but when the page is reloaded, it certainly returns to its original state.
Is it possible to make sure that when the page of the catalog section is reloaded, the button does not change (as I understand it, the handler needs to look at what products are in the basket and on the buttons output the corresponding option)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Ivanov, 2019-12-12
@dv1zhok

Try this way: https://camouf.ru/blog-note/6079/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question