=== MxChat WooCommerce Integration ===
Contributors: MxChat Team  
Plugin URI: https://mxchat.ai/  
Tags: WooCommerce, AI Chat, eCommerce, Shopping, Cart, Orders, Product Search  
Requires at least: 5.8  
Tested up to: 6.0  
Requires PHP: 7.4  
WC requires at least: 6.0  
WC tested up to: 8.0  
Stable tag: 1.2.0
License: GPLv2 or later  
License URI: http://www.gnu.org/licenses/gpl-2.0.html  

== Description ==

**MxChat WooCommerce Integration** is an add-on for the [MxChat](https://mxchat.ai/) plugin that enhances WooCommerce-powered stores with AI-driven chat functionalities. This extension enables intelligent product interactions, order management, shopping cart enhancements, and advanced product search capabilities through MxChat's AI interface.

### Key Features

* **🚀 Product Card Intent**: Displays a product image, name, price, and an **Add to Cart** button within the chat. AI responds to user queries with product details and recommendations.
* **🛒 Add to Cart Intent**: Detects previously discussed products in the chat and adds them to the user's WooCommerce cart when triggered.
* **📦 Order History Intent**: Retrieves user order history and provides information on order status, pricing, and past purchases. Allows users to inquire about specific orders by date, product, or status.
* **🔥 Product Recommendation Intent**: AI-driven product recommendations based on user's order history, current items in cart, and ongoing chat interactions. Displays up to **4 recommended products** with images, pricing, and reasoning.
* **🏁 Checkout Intent**: Guides users to the checkout page seamlessly from the chat interface.
* **🔍 Intelligent Filtered Product Search**: Revolutionary natural language product search that understands queries like "show me products under $30", "red shoes in stock", or "laptops between $500 and $1000". The AI automatically extracts price ranges, categories, attributes, and search terms to find exactly what customers are looking for.

### Filtered Product Search - New in v1.2.0!

The **Filtered Product Search** feature brings advanced, conversational product discovery to your store:

**How It Works:**
1. Customer asks a natural question like "show me affordable headphones" or "products under $50"
2. AI automatically detects the search intent and extracts filters (price, category, attributes)
3. Products are filtered and optionally re-ranked using semantic similarity
4. Results are displayed with product cards showing images, prices, and direct links

**Supported Filters:**
- **Price Ranges**: "under $30", "between $50 and $100", "less than $200"
- **Categories**: "in electronics", "from the shoes category"
- **Product Attributes**: "red color", "large size", "Nike brand"
- **Search Terms**: General keywords combined with filters

**Features:**
- Hybrid search combining vector-based trigger detection and AI filter extraction
- Manual price validation ensures only correctly priced products are shown
- Semantic re-ranking option for better relevance
- Multilingual support - responds in the user's language
- Configurable trigger phrases and similarity thresholds
- Displays up to 6 products with filters applied summary

== Installation ==

### Automatic Installation
1. Ensure you have **MxChat (Pro Version)** and **WooCommerce** installed and activated.
2. Navigate to **Plugins > Add New** in WordPress.
3. Search for `MxChat WooCommerce`.
4. Click **Install Now** and then **Activate**.

### Manual Installation
1. Download the plugin ZIP file.
2. Upload it to the `/wp-content/plugins/mxchat-woo/` directory.
3. Activate the plugin via **Plugins > Installed Plugins** in WordPress.

== Requirements ==
- **MxChat Pro** (Required for AI functionality)
- **WooCommerce** (6.0 or later)
- **WordPress** (5.8 or later)
- **PHP 7.4 or later**

== Configuration ==

### General Setup
1. Go to **MxChat > Settings > WooCommerce Integration**.
2. Enable WooCommerce integration.
3. Configure AI response settings for product recommendations and order history.

### Filtered Product Search Setup
1. Navigate to **MxChat > Intents**.
2. Enable the **Filtered Product Search** intent.
3. (Optional) Configure custom trigger phrases in the filtered search settings.
4. (Optional) Adjust similarity threshold for trigger detection.
5. (Optional) Enable semantic re-ranking for more relevant results.

**Trigger Phrase Examples:**
- "under $"
- "less than"
- "cheaper than"
- "price range"
- "show me products"
- "filter by"

### Project Structure
root/
├── admin/
│   ├── css/
│   │   └── mxchat-woo-admin.css
│   ├── js/
│   │   └── mxchat-woo-admin.js
│   └── partials/
│       └── mxchat-woo-settings-page.php
├── includes/
│   ├── class-mxchat-woo-activator.php
│   ├── class-mxchat-woo-admin.php
│   ├── class-mxchat-woo-cart-handler.php
│   ├── class-mxchat-woo-customer-handler.php
│   ├── class-mxchat-woo-filtered-search-handler.php
│   ├── class-mxchat-woo-loader.php
│   ├── class-mxchat-woo-order-handler.php
│   ├── class-mxchat-woo-product-handler.php
│   └── class-mxchat-woo-util.php
├── public/
│   ├── css/
│   │   └── mxchat-woo-public.css
│   └── js/
│       ├── mxchat-woo-cart.js
│       └── mxchat-woo-orders.js
├── mxchat-woo.php
├── readme.txt
└── update-checker.php

== Frequently Asked Questions ==

= Does this plugin work without MxChat? =
No, you must have **MxChat Pro** installed and activated.

= Can users add multiple items to the cart from the chat? =
Yes! The **Add to Cart** intent detects previously mentioned products and adds them accordingly.

= How does product recommendation work? =
The AI evaluates the user's **past orders, current cart, and chat interactions** to suggest relevant products.

= Does this plugin support variable products? =
Yes, MxChat WooCommerce can display and interact with variable product options.

= How does the filtered product search work? =
Users can search for products using natural language queries like "show me products under $30" or "red laptops in stock". The AI automatically extracts price ranges, categories, and attributes from the query, then filters products accordingly and displays results with product cards.

= Can I customize the filtered search trigger phrases? =
Yes! You can add custom trigger phrases in the filtered search settings to match your store's product terminology and customer language.

= What if filtered search returns products outside my price range? =
The plugin uses manual price validation to ensure only products within the specified price range are shown. Products without prices set are automatically excluded.

= Does filtered search work in multiple languages? =
Yes! The AI responds in the same language as the user's query, making it fully multilingual.

= Can I disable semantic re-ranking? =
Yes, semantic re-ranking is optional and can be disabled in the filtered search settings if you prefer results ordered by date.

== Support ==
For support and documentation, visit [https://mxchat.ai/support](https://mxchat.ai/support).

== Changelog ==

= 1.2.0 12.01.24 =
- NEW: Filtered Product Search - AI extracts price, category, and attribute filters from natural language queries
- NEW: Optional semantic re-ranking for improved search relevance
- Enhancement: Product recommendation titles are now clickable links
- Enhancement: Improved product card styling with better theme compatibility
- Fix: Price filtering now validates actual product prices accurately

= 1.1.9 11.19.24 =
- Fix: Filtered product search now includes actual product pricing information in AI prompts
- Enhancement: AI can now accurately reference product prices when responding to filter queries
- Improvement: Eliminates "I don't have pricing details" responses in filtered search results

= 1.1.8 11.19.24 =
- Fix: Order history intent now correctly receives user messages (fixed parameter order bug)
- Enhancement: Order history responses now fully support multilingual interactions
- Enhancement: Added markdown processing for order history responses (headings, bold, italic, links)
- Fix: Updated all AI system messages to be language-agnostic for better multilingual support
- Improvement: Order history now properly detects and responds in the user's language

= 1.1.7 11.9.25 =
- Enhancement: Fully multilingual AI responses for all add-to-cart and checkout actions
- Improvement: All error messages and user notifications now automatically detect and respond in the user's language
- Improvement: Replaced hardcoded English responses with AI-generated multilingual responses
- Feature: Language detection from user messages ensures consistent multilingual experience throughout the shopping flow

= 1.1.6 11.4.25 =
- Improvement: Enhanced the add to cart function with better product searching and prompting.
- Fixed: An error that could occur when retrieving order history.

= 1.1.4 =
- New Feature: Added functionality to turn off pricing & add to cart button within the product card.

= 1.1.3 =
- Improved multilingual support for product recommendation & add to cart action.

= 1.1.2 =
- Fixed markdown formatting not being processed correctly in product card responses
- Fixed product recommendations displaying raw markdown syntax instead of formatted text
- Fixed checkout action redirect functionality to properly redirect users to checkout page

= 1.1.1 =
- New option available to change the text on the add to cart button in the product card.

= 1.1.0 =
- Added Gemini Embedding Compatability

= 1.0.9 =
- Minor CSS update.

= 1.0.8 =
- bug fix to WooCommerce actions.

= 1.0.7 =
- Added support for Google Gemini models.
- Added new toolbar icons for viewing orders and cart.

= 1.0.6 =
* fixed a bug.

= 1.0.5 =
* Added support for various other embedding models from core plugin.

= 1.0.4 =
* Fixed product recommendation intent.

= 1.0.3 =
* Fixed product recommendation intent.

= 1.0.2 =
* Updated to include auto sync and clarity copy.

= 1.0.1 =
* Update Test

= 1.0.0 =
* Initial Release
* Added **Product Inquiry Intent** with product cards.
* Added **Order History Intent** for retrieving WooCommerce orders.
* Added **Add to Cart Intent** for adding discussed products to the cart.
* Added **Product Recommendation Intent** for personalized product suggestions.
* Added **Checkout Intent** for guiding users to checkout.

== Upgrade Notice ==

= 1.2.0 =
New Filtered Product Search with AI-powered filter extraction. Customers can search with natural language like "show me products under $30" and get accurate results. Improved product card styling and clickable titles in recommendations.

= 1.1.9 =
- Critical fix for filtered product search: AI now receives actual product pricing data and can accurately reference prices in responses

= 1.1.8 =
- Fixed order history intent parameter bug
- Enhanced multilingual support for order history
- Added markdown processing for better formatted responses

= 1.1.7 =
- Major enhancement: Complete multilingual support for all cart and checkout interactions
- All AI responses now automatically detect and match the user's language
- No more hardcoded English responses - seamless experience in any language

= 1.1.6 =
- Improvement: Enhanced the add to cart function with better product searching and prompting.
- Fixed: An error that could occur when retrieving order history.
