# SmartCart: Advanced Setup, Tips and Troubleshooting

> Advanced configuration, best practices, and answers to common SmartCart problems.

---

This page is part of the [SmartCart guide](/docs/smartcart). Start there for what the extension does, installation and the frequently asked questions.

## Advanced configuration

### Set free-shipping tiers from the command line

Free-shipping tiers can be set with `config:set` as a JSON array of rows, in the same format `config:show` prints. Quote the JSON so the shell passes it as one argument. A blank value clears the tiers.

```
bin/magento config:set moogento_smartcart/free_shipping_bar/tiers '[{"threshold":50,"label":"Add {{amount}} more for free shipping","sub_label":"*Extra charges apply for some destinations","tone":"urgency","is_free":"1"}]'
```

To review the current value, run `bin/magento config:show moogento_smartcart/free_shipping_bar/tiers`.

### Offline AI rule generation pipeline

The offline tooling layer mines your order history for frequently co-purchased product pairs, optionally enriches them with AI-generated semantic tags, and proposes draft rules. Nothing in this layer touches the storefront runtime.

#### What it does

1. **Association mining** (`smartcart:mine:associations`) reads qualifying orders in batches of 500, counts product co-occurrences, and calculates confidence and lift scores. Results land in the database.
2. **Product tagging** (`smartcart:tag:products`) sends product names, SKUs, and descriptions to the configured AI provider and stores semantic tags for each product. This step is optional but improves draft helper-text quality.
3. **Cold-start semantic pairing** (`smartcart:generate:semantic-pairs`, Pro plan) scores complementary-fit candidates for products with little or no co-purchase history, within a separate daily pair budget.
4. **Draft generation** (`smartcart:generate:drafts`) combines associations and tags into pending draft rules, and promotes ready semantic pairs into drafts at the same time. Each draft shows the mined evidence so you can judge whether it's worth approving. By default it covers every store view (plus all-store pairs); pass `--store=ID` to target one store view.

Association mining runs weekly on a cron schedule (by default Sunday at 4 AM). The rule-generation pipeline (mine → tag → generate drafts) then runs Monday at 5:15 AM, with a change-detection guard that skips weeks where no new orders or products exist.

#### Setup

1. Enable AI-Powered Rule Generation in:
   Stores > Configuration > Moogento > SmartCart > AI: Rules

2. Optionally select an AI Provider and paste the API key.

3. Run the pipeline manually for the first time:
   ```
   php bin/magento smartcart:mine:associations --since=90 --min-support=3
   php bin/magento smartcart:generate:drafts --min-confidence=0.1
   ```

4. Review drafts at **Moogento > SmartCart > Drafts**.

5. Click **Generate: Rules Now** in the config section to re-run at any time without SSH access.

#### Notes

- AI is **never** called during runtime recommendation generation - only the CLI commands and the weekly cron invoke external AI APIs.
- AI generation protects itself against a broken provider setup: after three consecutive failed provider calls (a connection error, or a response with no usable content) the run stops early, refunds the unused daily budget it reserved, and records the reason in `var/log/moogento_smartcart.log`. An incorrect API key never burns the day's AI budget.
- If micro-description generation gave up on some products after repeated provider failures, re-queue them with `php bin/magento smartcart:microdescriptions:generate --force` once the provider setup is corrected.
- If a Product One-Liner Attribute is configured, products with a value there never reach the AI provider - `smartcart:microdescriptions:generate` reports them as "already had a product one-liner" and returns their reserved daily budget unused.
- Associations require orders with 2+ distinct products and status `processing` or `complete`. Fewer than 3 orders sharing a pair (the `--min-support` default) produce no association rows.
- `--min-confidence=0.1` means "at least 10% of orders containing product A also contained product B". Raise this for higher-confidence suggestions; lower it to see more (but noisier) drafts.
- The Generate button in admin (`AI: Rules > Generate: Rules Now`) runs the same pipeline in force mode, bypassing the change-detection skip. Use it after adding a new product range or importing a batch of orders.

---

## Tips & best practices

- Start with 1-2 rules covering your highest-volume cart scenarios before scaling up. Check 30-day stats before creating more - rule quality matters more than quantity.
- Keep Maximum Offers at 2. Showing 3 or more offer tiles increases visual noise and typically reduces conversion on each individual tile.
- Set a cache TTL of at least 300 seconds in production. A TTL of 0 runs the full pipeline on every cart page load and adds latency.
- Use priority numbers with gaps (10, 20, 30) so you can insert new rules between existing ones without renumbering.
- Enable event tracking from day one. The 30-day stats columns on the Rules grid are the fastest way to tell which rules are worth keeping.
- If a rule's dismiss rate is consistently above 40-50%, the pool is probably too broad or the product is not a good fit for that trigger. Narrow the pool or revise the trigger.
- Use the Disable: When Coupon Applied toggle if your promotions already offer a clear incentive - adding an upsell alongside a coupon code can feel pushy and reduce trust.
- Run association mining against 90 days of orders first. If your catalogue changes seasonally, re-run after each season ends.
- Approve AI-generated drafts selectively. Check the evidence column - pair count below 5 or confidence below 15% usually means a weaker association. Reject freely.

---

## Troubleshooting

### No recommendations appear on the cart page

- **Cause:** Module is disabled, no active rules exist, or placement is off
- **Check:** Stores > Configuration > Moogento > SmartCart > Setup: General > Enable = Yes
- **Check:** Stores > Configuration > Moogento > SmartCart > Where: Placements > Show: Cart Page = Yes
- **Check:** Moogento > SmartCart > Rules - at least one rule must be enabled and scoped to the current store

### Recommendations appear but never include a specific product

- **Cause:** The product is filtered out by a guardrail
- **Check:** The product is in stock and salable
- **Check:** The product SKU is not in Excluded: Product SKUs (`moogento_smartcart/eligibility/excluded_skus`)
- **Check:** The product's category is not in Excluded: Categories (`moogento_smartcart/eligibility/excluded_categories`)
- **Check:** The product is not already in the shopper's cart (SmartCart never suggests items already in cart)
- **Check:** If history suppression is enabled, the shopper may have purchased the product before

### A dismissed offer keeps coming back after the browser is refreshed

- **Cause:** The dismissal TTL has expired, or localStorage is being cleared between sessions
- **Check:** Stores > Configuration > Moogento > SmartCart > Limits: Eligibility & Suppression > Remember: Dismissed Offers - increase the value if needed
- **Note:** The dismissal key includes the context hash - if the cart changes (a different item is added), the context hash changes and dismissed offers may reappear

### Rule stats columns show zeros even though the module is active

- **Cause:** Event tracking is disabled
- **Check:** Stores > Configuration > Moogento > SmartCart > Setup: General > Enable: Event Tracking = Yes
- **Note:** Stats aggregate on a 15-minute cron. Allow up to 15 minutes after enabling before expecting data

### Mining produces no associations or drafts

- **Cause:** Not enough qualifying orders, or minimum support threshold is too high
- **Check:** Orders must have status `processing` or `complete` and contain 2+ distinct products
- **Try:** Lower `--min-support` to 2, or extend `--since` to 180 days
- **Check:** `var/log/moogento_smartcart.log` for pipeline output

### AI provider returns no results or a 401

- **Cause:** API key is missing, wrong provider selected, or key does not match the provider
- **Check:** Stores > Configuration > Moogento > SmartCart > AI: Rules - verify Provider and API Key match
- **Check:** `var/log/moogento_smartcart.log` - the error from the provider API is logged there
- **Note:** Changing the provider requires a matching API key - a key issued for OpenAI will not work if Provider is set to Anthropic

### Free-Shipping Bar does not appear on the storefront

- **Cause:** Pro plan not active, no tier rows configured, or the bar is not enabled for the relevant placement
- **Check:** Stores > Configuration > Moogento > SmartCart > Pro: Free Shipping & Tier Boost > Enable: Free-Shipping Bar = Yes
- **Check:** At least one row exists under Tiers: Free-Shipping Thresholds with a positive threshold amount
- **Check:** The relevant placement toggle (Show: Mini-Cart / Cart Page / Checkout Page) is set to Yes
- **Check:** Stores > Configuration > Moogento > License - the SmartCart Pro plan must be active

### Smart Bundles discount is not applied at checkout

- **Cause:** The shopper selected fewer items than the Minimum Items to Qualify for Discount setting
- **Check:** Stores > Configuration > Moogento > SmartCart > Pro: Smart Bundles > Minimum Items to Qualify for Discount - confirm the minimum matches the number of bundle items the shopper selected
- **Check:** Discount Mode is not set to None
- **Note:** The bundle discount appears in the order summary as "Bundle Discount" and requires a Pro plan

### Malware scanner flags Helper/Moo.php

- **Cause:** Your host's malware scanner (often Imunify360 on cPanel hosting) heuristically flags the encoded license-check files that ship inside every paid Moogento extension. The files are genuine and unchanged - the encoding protects the license check from tampering.
- **Resolution:** Add the files to the scanner's ignore list so the warnings stop, and restore any file the scanner already quarantined. Both steps, plus how to verify the files are byte-for-byte what we shipped, are covered in the **moogento-license-file-protection** guide in the Magento guides section.

---

## Other pages in this guide

- [SmartCart overview, installation and FAQs](/docs/smartcart)
- [SmartCart: Set Up Rules, Suppression and AI Drafts](/docs/smartcart-rules-and-ai-drafts)
- [SmartCart: Settings and Features Reference](/docs/smartcart-features-reference)

<!-- docs-split: part-of="smartcart" -->
