=== AboveWP Add To Cart Upsell Popup ===
Contributors: wpabove, pdpetrov98
Tags: woocommerce, upsell, popup, add-to-cart, cross-sell
Requires at least: 5.0
Tested up to: 7.1
Requires PHP: 7.2
WC requires at least: 5.0
WC tested up to: 11.1
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Display upsell products in a popup after add-to-cart. Works with any theme.

== Description ==

**AboveWP Add To Cart Upsell Popup** is a powerful WordPress plugin that displays upsell products in a beautiful popup after customers add items to their cart. **Now enhanced for universal theme compatibility!**

= ✨ Key Features =

* **Universal Theme Compatibility**: Works with any WordPress theme, including custom themes, Elementor, and page builders
* **Multiple Add-to-Cart Detection Methods**: Supports both AJAX and non-AJAX add-to-cart scenarios
* **Flexible Upsell Sources**: Choose from WooCommerce upsells, global products, or category-based upsells
* **Responsive Design**: Optimized for all devices and screen sizes
* **Customizable Appearance**: Colors, text, and button visibility options
* **Performance Optimized**: Lightweight and cache-friendly
* **Accessibility Ready**: WCAG compliant with keyboard navigation and screen reader support

= 🔧 Enhanced Compatibility Features =

**Add-to-Cart Detection**
The plugin now uses **5 different methods** to detect add-to-cart actions:

1. **WooCommerce AJAX Events**: Standard `added_to_cart` event
2. **Form Submission Monitoring**: Detects non-AJAX form submissions
3. **Universal Button Clicking**: Monitors all types of add-to-cart buttons
4. **URL Parameter Detection**: Handles redirects with add-to-cart parameters
5. **Success Message Detection**: Detects WooCommerce success messages

**Supported Add-to-Cart Button Types**
* Standard WooCommerce buttons (`.single_add_to_cart_button`, `.add_to_cart_button`)
* AJAX buttons (`.ajax_add_to_cart`, `.product_type_simple`)
* Custom theme buttons (`[name="add-to-cart"]`, `.wc-add-to-cart`)
* Page builder buttons (Elementor, Gutenberg blocks)
* Custom implementations with data attributes

**Theme Compatibility**
* ✅ **Storefront**: Full compatibility (as before)
* ✅ **Astra**: Full compatibility
* ✅ **GeneratePress**: Full compatibility
* ✅ **OceanWP**: Full compatibility
* ✅ **Divi**: Full compatibility
* ✅ **Elementor Pro**: Full compatibility
* ✅ **Custom Themes**: Enhanced detection methods ensure compatibility

= 🎯 Upsell Sources =

**1. WooCommerce Upsells**
Uses the built-in WooCommerce upsells defined for each product.

**2. Global Products**
Define specific product IDs to show as upsells for all products.
Example: 123, 456, 789

**3. Category-based Upsells**
Set different upsell products for each product category.

= 🎨 Customization Options =

* **Popup Title**: Customize the header text
* **Success Message**: Personalize the "added to cart" message
* **Button Text**: Customize all button labels
* **Colors**: Set colors for prices and buttons
* **Button Visibility**: Show/hide View Cart, Checkout, and Continue Shopping buttons

= 🌐 Browser Support =

* Chrome 70+
* Firefox 65+
* Safari 12+
* Edge 79+
* Internet Explorer 11 (limited support)

= ⚡ Performance Metrics =

* **JavaScript Bundle**: ~15KB minified
* **CSS Bundle**: ~5KB minified
* **Page Load Impact**: <100ms
* **Memory Usage**: <1MB

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/abovewp-atc-popup-upsell/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Navigate to **AboveWP > ATC Upsell Popup** to configure settings
4. Configure your upsell products and customize the popup appearance

== Frequently Asked Questions ==

= Why is the popup not showing? =

1. **Check Plugin Settings**: Ensure the plugin is enabled in settings
2. **Verify Upsell Products**: Make sure upsell products are properly configured
3. **Theme Conflicts**: Check if your theme overrides WooCommerce functionality
4. **Caching**: Clear all caches (site, CDN, and browser)
5. **JavaScript Errors**: Check browser console for errors

= Does it work with my theme? =

Yes! The plugin is designed for universal theme compatibility. It works with:
* All popular WordPress themes (Astra, GeneratePress, OceanWP, Divi, etc.)
* Custom themes
* Page builder themes (Elementor, Beaver Builder, etc.)
* WooCommerce-specific themes

= Why does it work on some pages but not others? =

The plugin now loads on all pages with WooCommerce content. If you're using custom add-to-cart buttons, ensure they have proper data attributes. The plugin handles both AJAX and non-AJAX scenarios automatically.

= How can I improve performance? =

1. **Reduce Upsell Count**: Display fewer upsell products
2. **Optimize Images**: Compress upsell product images
3. **Use Caching**: Implement a caching plugin for better performance

= How do I enable debug mode? =

Add this to your `wp-config.php` file:
`define('WP_DEBUG', true);`
`define('WP_DEBUG_LOG', true);`

Then check the browser console for debug messages.

= How do I add custom add-to-cart buttons? =

If your theme uses custom add-to-cart buttons, ensure they have one of these attributes:

**Method 1: Product ID in value**
`<button name="add-to-cart" value="123">Add to Cart</button>`

**Method 2: Data attribute**
`<button data-product-id="123">Add to Cart</button>`

**Method 3: URL parameter**
`<a href="?add-to-cart=123">Add to Cart</a>`

**Method 4: Within form**
`<form class="cart">`
`    <input type="hidden" name="product_id" value="123">`
`    <button type="submit">Add to Cart</button>`
`</form>`

= Can I customize the popup appearance? =

Yes! The plugin offers extensive customization options:
* Custom colors for prices and buttons
* Customizable text and messages
* Button visibility settings
* Responsive design options

= Does it work with caching plugins? =

Yes! The plugin is designed to work with aggressive caching through:
* Session-based fallbacks
* Transient data storage
* Browser storage integration
* Enhanced detection methods

== Screenshots ==

1. Plugin settings page - Configure upsell sources and customization options
2. Popup example - Beautiful upsell popup with product suggestions
3. Mobile responsive design - Optimized for all devices
4. Color customization options - Match your brand colors

== Changelog ==

= 1.0.1 - Enhanced Compatibility Update =
* **Added**: 5 different add-to-cart detection methods
* **Added**: Support for non-AJAX add-to-cart scenarios  
* **Added**: Universal button selector system
* **Added**: Enhanced page detection for page builders
* **Added**: Improved session and transient handling
* **Added**: Better caching compatibility
* **Improved**: CSS with !important declarations for theme override protection
* **Improved**: JavaScript error handling and fallbacks
* **Improved**: Mobile responsiveness
* **Fixed**: Product ID extraction from various button types
* **Fixed**: Popup display on custom theme implementations
* Tested up to WordPress 7.1 and WooCommerce 11.1

= 1.0.0 - Initial Release =
* Initial release
* Basic AJAX add-to-cart support
* WooCommerce upsells integration
* Customizable popup design

== Upgrade Notice ==

= 1.0.1 =
Major compatibility update! Now works with any WordPress theme. Includes 5 different add-to-cart detection methods, better caching support, and enhanced mobile experience.

= 1.0.0 =
Initial release of the plugin.

== External Services ==

This plugin loads the Inter font from Bunny Fonts (https://fonts.bunny.net) on the plugin's admin settings pages. This is used to style the plugin's administration interface. No user data is sent to this service; only a standard HTTP request is made to load the font CSS file. This request is only made when an admin user visits the plugin's settings pages.

Bunny Fonts is a GDPR-compliant font delivery service provided by BunnyWay d.o.o.

* Service: [Bunny Fonts](https://fonts.bunny.net)
* Terms of Service: [https://bunny.net/tos/](https://bunny.net/tos/)
* Privacy Policy: [https://bunny.net/privacy/](https://bunny.net/privacy/)

== Developer Information ==

= Hooks and Filters =

**Actions**
`// Before popup is shown`
`do_action('abovewp_atc_before_popup', $product_id, $upsell_data);`

`// After popup is shown`
`do_action('abovewp_atc_after_popup', $product_id, $upsell_data);`

**Filters**
`// Modify upsell data`
`$upsell_data = apply_filters('abovewp_atc_upsell_data', $upsell_data, $product_id);`

`// Modify popup HTML`
`$popup_html = apply_filters('abovewp_atc_popup_html', $popup_html, $upsell_data);`

`// Add custom button selectors`
`$selectors = apply_filters('abovewp_atc_button_selectors', $selectors);`

= Custom Integration =

`// Manually trigger popup with custom data`
`if (typeof AtcPopupUpsell !== 'undefined') {`
`    AtcPopupUpsell.showPopup({`
`        added_product_name: 'Product Name',`
`        upsell_products: [`
`            {`
`                id: 123,`
`                name: 'Upsell Product',`
`                price_html: '$19.99',`
`                image: 'image-url.jpg'`
`            }`
`        ]`
`    });`
`}` 