The “Buy”, “Add to wishlist” and “Add to comparison” buttons in the Elbuz search window call your site's JavaScript: the product goes into the site cart from search. For common CMSs the app fills it in.
When you need this:
- Cards in search lack a “Buy” button — it appears with add-to-cart code.
- Your site is on OpenCart, WooCommerce, Magento, Horoshop or Elbuz CMS — choosing the CMS fills all six fields.
- The Elbuz catalog has no product ID from your CMS — the widget reads it from the product page.
Where to start: the “Setup” tab → choose “CMS ID” → check the code on the “Events” tab.
What action buttons in the search window can do
- Take ready-made code for your CMS — choosing the CMS and theme fills in the button code.
- Run your code — six actions: add to and remove from the cart, wishlist and comparison.
- Pass product data to the code — the ID in Elbuz and in the CMS, name, price, address, photo.
- Find the product ID on the page — when the catalog doesn't have it.
Which buttons appear on the product card at all is set on the “View” tab — action buttons.
How to get ready-made code for your CMS
On the “Setup” tab, in the “Site and search box” card, choose “CMS ID”, and for OpenCart also “CMS theme”. The app fills in the button code on the “Events” tab, the selectors, the styles the CMS needs and page addresses, and for Horoshop also “Product ID extraction”. Empty fields are filled right away; before replacing what you've already entered, the app lists the fields and asks: “Replace”, “Fill empty only” or “Cancel”. Details: what choosing a CMS fills in.
| CMS ID | What code is filled in |
|---|---|
| OpenCart | all six actions; with the OCT ShowCase, OCT Deals or OCT Promo theme, the code also updates the cart, wishlist and comparison counters in the theme header |
| Elbuz CMS, WooCommerce (WordPress), Magento (Adobe Commerce), Horoshop | all six actions |
| Shopify | only adding to and removing from the cart |
| PrestaShop, BigCommerce, Squarespace Commerce | no code — the fields stay as they are, you write the code yourself |
For WooCommerce, wishlist and comparison work only with separate plugins for these lists on the site.
What each button's code does
The “JS code for buttons and events” card has six fields: “Add to cart”, “Remove from cart”, “Add to wishlist”, “Remove from wishlist”, “Add to comparison”, “Remove from comparison”. The code runs in the shopper's browser when they click the matching button in the search window.
- The “Buy” button appears on the card only when all of these hold: it's turned on in the “View” tab, the product is in stock, the “Add to cart” field is filled in, and the product has an ID from the CMS or ID extraction is filled in. Without code there's no button.
- Wishlist and comparison appear even without code: the product goes into the list inside the search window, but nothing reaches your site's lists.
- Code with an error — the action on the site doesn't happen, and the shopper sees a widget window with an error.
1
Add to cart2
Remove from cart3
Wishlist4
Comparison- The code runs in the shopper's browser; the product ID in the CMS is productData.id_ext.
- Without add-to-cart code there is no “Buy” button on the card.
- Adding and removing are separate fields.
- The code was inserted by choosing “CMS ID” and “CMS theme”.
What product data the code receives
The code has the productData variable — the product whose button was clicked. The code that removes from lists receives the same CMS ID as the add code, including one taken from the product page.
| Field | What it contains |
|---|---|
productData.id | product ID in Elbuz |
productData.id_ext | product ID in your CMS — this is what the site cart expects |
productData.name, sku, mpn | name, store SKU, manufacturer part number |
productData.price | the price as shown on the card, with the currency sign |
productData.url, image_url | product page address and photo |
productData.category_id, category, brand | category and brand |
Besides the product, the code has showCartSuccessModal and showErrorModal — the widget's “Product added” and “Error” windows — and fetch for a request to the site.
An example for an OpenCart cart that expects the product ID in the CMS:
fetch('index.php?route=checkout/cart/add', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({product_id: productData.id_ext, quantity: 1})
});
How to take the product ID from a site page
The site cart accepts a product by its ID in the CMS. When the Elbuz catalog has no such ID — the catalog was built not by exporting to the site but from another source — fill in the “Product ID extraction” card on the “Events” tab.
- “CSS selector or Regex to extract product ID from page” — what to look for on the product page.
- “Extraction type” — CSS (default) or Regex.
- “Always extract ID from product page, even if id_ext is filled” — when the catalog has an ID, but not the one the cart needs.
What happens when the shopper clicks a button:
- If the product has an ID from the CMS and the “Always…” checkbox is cleared, that ID is used and the page isn't loaded.
- Otherwise the shopper's browser loads the product page using its link from search.
- For CSS, the first element found is used: its field value, the
data-idordata-product-idattribute, thecontentattribute or the text — whichever is found first. - For Regex, the first group in parentheses is used:
"product_id":\s*(\d+)gives a number. - The ID found goes into
productData.id_ext, and the button code runs. Repeated clicks on the same site page don't load the product page again.
If the page didn't open or nothing was found, the button code runs with the ID it had. That's why product links must lead to your site — see the product URL template.
1
What to look for2
CSS or Regex3
Always from the page- The product page element holding its ID in the CMS.
- Regex takes the first group in parentheses.
- Even when the catalog has the CMS ID.
Scenarios
An OpenCart site with the OCT Deals theme
What to do. Enter the “Site address”, choose OpenCart in “CMS ID” and OCT Deals in “CMS theme”.
What you get. Buttons in the search window put the product into the site cart and update the counters in the theme header; below the cart list in the search window there are buttons to go to the cart and to checkout.
The catalog is built from suppliers and has no site product IDs
What to do. Find an element with the ID on your site's product page — for example, the hidden field input[name="product_id"] — and enter it in “CSS selector or Regex to extract product ID from page”.
What you get. On the first click, the widget opens the product page in the background, takes the ID and passes it to the site cart.
You need your own action after adding
What to do. At the end of the “Add to cart” code, add your own call, for example opening your theme's side cart.
What you get. After adding, the shopper sees the site cart right away.
What to do when a button doesn't work
| What you see | Why | What to do |
|---|---|---|
| The card has no “Buy” button | the “Add to cart” code is empty, the product is out of stock, or there's no product ID from the CMS | choose the CMS or enter the code; fill in “Product ID extraction” |
| The product is in the wishlist in the search window but not on the site | the code field for this action is empty | choose the CMS or enter the code |
| The wrong product is added | the code uses productData.id instead of id_ext | pass productData.id_ext to the cart |
| The site cart responds with a “product not found” error | the CMS product ID in the catalog differs from the one on the site | fill in “Product ID extraction” and turn on “Always extract…” |
FAQ
Why do product cards in search have no “Buy” button?
It appears only with “Add to cart” code, for in-stock products and with a product ID from the CMS. Choose the CMS or enter the code, and fill in “Product ID extraction” if needed.
What should I choose for an Elbuz CMS store?
Elbuz CMS in “CMS ID”. For a store created in Elbuz, search is set up automatically when the store is created.
How do I open the theme's side cart after adding?
Add a call that opens your theme's cart at the end of the “Add to cart” code. For OpenCart with OCT themes, the code already does this.
Which is better — CSS or Regex?
CSS, if the ID is in an attribute or a page field. Regex, if the ID is only in the text of a page script.
Does ID extraction slow down the button?
Only the first click on a product: the browser loads its page. Repeated clicks on the same page use the ID already found.
Where it is and who has access
- Menu
- Directories → Categories → the “Widget settings - Smart search” tile → the “Events” tab
- Other entry points
- ready-made code — the “Setup” tab, the “CMS ID” and “CMS theme” fields
- Access right
- the “Smart product search widget” window in “Group permissions”
- Prepare
- know how your site's cart adds a product
Related topics
- For the big picture — smart search on your website: what it does and where to start.
- If the button isn't visible on the product card — which buttons to show.
- If a button leads to the wrong product page — how to set up links.
- If the widget isn't on the site yet — how to connect smart search.
