Here you can find instructions on how to install and configure the Cartally AI Search widget in your WooCommerce store.Documentation Index
Fetch the complete documentation index at: https://docs.cartally.co/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Step 1 — Add the widget script
Add the script to your theme’sfooter.php file, just before </body>:
- In the WordPress admin, go to Appearance → Theme File Editor.
- Open
footer.php(ortheme-footer.phpin block themes). - Paste the following code just before the
</body>tag:
- Click Update File.
Tip: To prevent losing the script after a theme update, use a child theme. If you’re already using a child theme, edit its footer.php instead.
Step 2 — Configure settings in the Cartally panel
- Log in to app.cartally.co.
- Go to Integration and enter your store’s URL.
- Select WooCommerce as the platform.
- Provide your Consumer Key and Consumer Secret (generated in WooCommerce → Settings → Advanced → REST API).
- Click Save & Connect — Cartally will verify the connection and start syncing products.
Generating WooCommerce API keys
- In your WordPress admin, go to WooCommerce → Settings → Advanced → REST API.
- Click Add key.
- Set a Description (e.g., “Cartally”).
- Set Permissions to Read.
- Click Generate API key.
- Copy the Client Key and Private Key — paste them in the Cartally integration panel.
Security: Read-only permissions are sufficient. Cartally never modifies your products or orders.
Step 3 — Customize the widget
Go to Widget in the Cartally panel sidebar to set:- Accent Color — the main brand color used in the widget UI.
- Logo URL — a publicly accessible URL to your store’s logo.
Widget configuration options
You can customize the widget by addingdata- attributes to the script tag:
| Attribute | Description | Example |
|---|---|---|
data-color-accent-primary | Accent color (hex) | #e63946 |
data-logo-url | URL to your shop logo | https://myshop.com/logo.png |
data-language | Force a specific language | en |
data-currency | Force a specific currency | USD |
data-trigger-selector | CSS selector for custom trigger elements | .search-btn |
Full example with all options
Automatic language and currency detection
The widget automatically detects the language and currency that the customer is currently using, so you typically don’t need to setdata-language or data-currency manually.
On WooCommerce the widget reads:
- Language — from the
<html lang="...">attribute (set by WordPress based on the active locale or WPML/Polylang plugin). - Currency — from the
.woocommerce-Price-currencySymbolelement on the page and maps the symbol to an ISO code (e.g.,$→USD,€→EUR,zł→PLN).
You can override the automatic detection by explicitly settingdata-languageanddata-currencyon the script tag. This is recommended if your multi-currency plugin does not render.woocommerce-Price-currencySymbolon every page.
Attaching the widget to any element
The widget can be triggered by any element on the page — a button, link, icon, or any other HTML element. You choose the element by providing its CSS class or ID in thedata-trigger-selector attribute.
Option A — Use data-trigger-selector on the script tag
Specify a CSS selector (class or ID) that matches the element(s) you want to use as the widget trigger:
Option B — Add a class directly to the element
If you prefer, add thecartally-trigger class to any element in your theme:
Common WooCommerce theme selectors
| Theme | Selector |
|---|---|
| Storefront | .site-search, .site-header .search |
| Astra | .ast-search-icon, .astra-search-icon |
| OceanWP | #searchform-header .search-toggle |
| Flatsome | .icon-search, .searchform-wrapper |
| GeneratePress | .navigation-search |
Tip: To find the correct selector for your theme, right-click the search element in your browser → Inspect → note theclassoridof the element.
Multilingual support
Cartally automatically detects and indexes products in all languages configured in your WooCommerce store.- Search works in the language currently selected by the customer.
- Autocomplete suggestions match the store’s active language.
- Compatible with WPML, Polylang, and TranslatePress.
- If a product is not translated, the store’s default language is used.
Currencies and localization
Cartally supports currencies configured in your store.- Customers always see prices in their currently selected currency.
- The widget auto-detects the active currency from the page.
- If a price is not available in a given currency, the store’s default currency is used.
Product synchronization
Products are synchronized with Cartally via the WooCommerce REST API.- An initial full sync runs when you first connect the integration.
- Subsequent syncs run periodically to keep the catalog up to date.
- You can trigger a re-sync from the Integration page in the Cartally dashboard.
Troubleshooting
Widget does not appear
Check if:- The script tag is present in the page source (View Source or F12 → Elements).
- The
srcURL (https://app.cartally.co/widget.js) is not blocked by a Content Security Policy, ad blocker, or security plugin (e.g., Wordfence). - There are no JavaScript errors in the browser console (F12 → Console).
- If using a caching plugin, clear the cache after adding the script.
Products not appearing in search
Check if:- The product is published (not draft or private).
- The product has a name and description.
- The WooCommerce REST API keys have Read permissions.
- The sync job has completed (check Integration page in the Cartally panel).
- Your site is accessible from external servers (not blocked by
.htaccess, Cloudflare firewall rules, or IP restrictions).
Wrong language or currency
If the widget shows the wrong language or currency:- Check
document.documentElement.langin the browser console — it should match the active language. - Check if
.woocommerce-Price-currencySymbolis present on the page (inspect a product price element). - If detection fails, set
data-languageanddata-currencyexplicitly on the script tag.
AI does not respond or is slow
Possible reasons:- The AI request limit has been reached.
- There is temporary system overload.
- The query is very complex.
Caching conflicts
If the widget behaves inconsistently:- Exclude
widget.jsfrom caching in your performance plugin (WP Super Cache, W3 Total Cache, LiteSpeed Cache). - The widget script has
deferso it should not block page rendering. - If using Cloudflare Rocket Loader, add
data-cfasync="false"to the script tag.
