Add to cart
Make the «В корзину» button in search and chat add to your own cart.
Products in search results and in the consultant's answers have a «В корзину» button. Your cart stays yours: the button calls it in one of three ways.
| Method | What happens |
|---|---|
| JavaScript function | We call window.<yourFunction>(externalId, qty) |
| URL template | We open your URL with {id} and {qty} filled in, e.g. /cart/add?id={id}&qty={qty} |
| None | The button opens the product page — the default |
externalId is the product ID from your catalog — <offer id> in the feed or id in the push API.
JavaScript function
The best option when your cart already has one, which is usual for 1C-Bitrix and most themes. It keeps the shopper on the page:
window.addToCart = function (externalId, qty) {
// your existing cart call, e.g. BX.ajax or fetch('/cart/add', …)
};After the call the widget marks the product as added and shows «Добавлено в корзину». If the function is missing or throws, we open the product page instead, so the shopper can still buy.
URL template
For carts that add by link. The page at the URL must add the product and show the cart or return the shopper; {id} is URL-encoded.
What we count
Every press sends an add_to_cart event with the product and where it happened — search or chat. It feeds your LockStock report; your own analytics are untouched.