=== PW - Ofertas Avanzadas Lite ===
Contributors: pezweb
Tags: woocommerce, discounts, coupons, promotions, marketing
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 2.26.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Run WooCommerce discount campaigns in minutes — three marketing strategies, a step-by-step wizard, and optional product badges. No coding needed.

== Description ==

**PW - Ofertas Avanzadas Lite** lets you design, launch, and manage discount campaigns in WooCommerce based on real marketing strategies. A guided wizard walks you through every setting, automatic matching counts tell you how many products qualify before you publish, and optional badge overlays let shoppers know a deal is live.

Whether you're clearing slow-moving stock, rewarding bulk buyers, or discounting items that are approaching their sell-by date, you get purpose-built strategies instead of generic coupon workarounds.

= Guided campaign wizard =

Every campaign starts with the same clean wizard:

* Choose a strategy and give the campaign a name.
* Pick your target products or categories — the wizard filters out already-selected items and shows a live matching count as you adjust the audience.
* Configure the discount tier for that strategy (percentage or fixed amount, validated in real time).
* Set a start/end date if needed.
* Publish — the discount applies automatically at checkout and on product pages.

= Three ready-made marketing strategies =

**Basic product discount**
A straight percentage or fixed-amount reduction on one or more products. Use it for seasonal promotions, welcome offers, or clearance sales where you want a simple, clearly labelled markdown.

**Buy X, pay Y**
Automatically applies when a customer adds the required quantity to the cart — no coupon code needed. Set up 2-for-1, 3-for-2, 5-for-4, or any combination. Ideal for consumer goods, bundles, and inventory you want to move fast. You can cap how many times the deal applies per order.

**Expiry-based tiered discount**
Built for perishable and time-sensitive items: food, beverages, cosmetics, pharmaceuticals. Define discount tiers by days-until-expiry — for example, 30 days left = 10 % OFF; 15 days = 20 % OFF; 7 days = 35 % OFF. WooCommerce calculates the right tier automatically, so you reduce waste without manually repricing products every week.

= Product badges =

Opt in to badge overlays on your WooCommerce product images. When a campaign is live, an "On sale" or custom-label badge appears on the product card and product page — giving customers a visual cue without requiring theme edits or shortcodes.

= Campaign management =

All active and scheduled campaigns live in a single dashboard. Enable, pause, or delete a campaign in one click. Edit strategy settings at any time and the changes take effect on the next page load. Campaigns are stored in dedicated database tables (created automatically on activation) and never interfere with WooCommerce's native coupon system.

= Languages =

The plugin is written in English. A full Spanish (`es_ES`) translation is included and loads automatically when the site locale is set to any `es_*` variant.

= Pro edition =

A separate Pro edition adds advanced strategies (bulk volume discounts, attribute-quantity tiers), built-in analytics, and additional audience filters. It is sold directly by the author and is not distributed through this WordPress.org listing.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install it from **Plugins → Add New**.
2. Activate the plugin.
3. Make sure **WooCommerce** is installed and active — the plugin will show an admin notice if it is not.
4. Open the **Offers** menu in the WordPress admin sidebar to create your first campaign.

== Frequently Asked Questions ==

= Does it work without WooCommerce? =

No. WooCommerce must be installed and active. The plugin checks for this on every admin load and shows a clear notice if the dependency is missing.

= Where are campaign data and settings stored? =

In custom database tables created during plugin activation. No data is stored in `wp_options` or `wp_postmeta`, and uninstalling the plugin removes those tables cleanly.

= Can I run more than one campaign at the same time? =

Yes. Multiple campaigns can be active simultaneously. If a product qualifies for more than one campaign, the stacking behaviour follows the priority order you configure — the default is to apply the highest-priority campaign.

= Do campaigns affect WooCommerce coupons? =

Campaigns are independent of WooCommerce's coupon system. A customer can use a native coupon code and still benefit from an active campaign on the same order.

= How are the badges shown in the storefront? =

Badge overlays render on WooCommerce's standard product image hooks, so they work with most themes out of the box. Products without a featured image do not receive a badge wrapper, avoiding layout issues. If your theme has a heavily customised product loop you may need to check the output, but no theme file edits are required.

= Will this work with my page builder? =

Campaigns apply at the WooCommerce cart and pricing layer, so they work regardless of how product pages are built. Badge overlays rely on standard WooCommerce hooks; if your page builder replaces those hooks entirely (some do), badges may not appear on the front end — the discount itself is unaffected.

= What is the difference between Lite and Pro? =

Lite ships three strategies: basic discount, buy X pay Y, and expiry-based tiered discount. The Pro edition adds bulk-volume discounts, attribute-quantity tiers, campaign analytics, and additional audience filters. Pro is sold separately by the author and is not available through WordPress.org.

== External services ==

This plugin does **not** call remote APIs or send store data to third-party servers in the background. Wizard and dashboard admin layouts use utility CSS **bundled** in the plugin (`assets/css/pwoa-tailwind-admin.css`). The bundled design library (`pw/backend-ui`) loads its own JavaScript and CSS from the plugin package only; it does not load the Tailwind Play CDN.

== Changelog ==

= 2.26.1 =
* **Fix:** Lite package now ships `ProductPriceHandler.php` and `CampaignPricingService.php` (fixes fatal error on plugin load after updating from WordPress.org).

= 2.26.0 =
* **Lite scope:** the wizard and storefront ship three campaign strategies — basic discount, buy X pay Y, and expiry-based (bulk volume and attribute-quantity strategies are not offered in Lite; legacy rows for removed strategies are ignored at runtime).
* **Wizard / admin:** stronger AJAX category search (hierarchy, tighter matching, deduplication), product search improvements (variations, legacy parent handling, hiding already-selected picks), matching-count refresh when audience filters change, and consistent percentage vs fixed tier fields with validated 0–100% values (decimal-comma input supported).
* **Stability:** empty `stacking_mode` values default to `priority` when saving campaigns.
* **Fix:** admin no longer fatals when an older bundled `pw/backend-ui` copy lacks `CORE_STYLE_HANDLE` (backward-compatible stylesheet dependency).
* **Fix:** Lite package now includes `ProductPriceHandler` and `CampaignPricingService` (required by cart and catalog pricing since recent releases).
* **Code quality:** nonce verification paths cleaned up (removed blanket PHPCS `NonceVerification` suppressions in favour of explicit checks).
* **Dependencies:** `pw/backend-ui` pinned to **1.4.7** in the distributed package.

= 2.2.5 =
* **Storefront:** products without a featured image no longer get offer badges wrapped around the main image—fewer odd layouts on the product page, including with WooCommerce's own markup and Elementor's Product Image widget.
* **Admin:** the compiled Tailwind stylesheet now loads right after BackendUI's core CSS (`AssetsManager::CORE_STYLE_HANDLE`), so utility classes sit where they should with the bundled `pw/backend-ui`.
* **i18n:** more Spanish (`es_ES`) strings covered in the bundled translation files (`.po` / `.mo`).

= 2.2.4 =
* Build: include `CampaignPostSanitizer.php` in the Lite package (fixes campaign save and conditional validation in the wizard).

= 2.2.2 =
* i18n: WordPress 6.7+ compatibility — defer admin bootstrap (BackendUI, menus) to the `init` action so the `pezweb-ofertas-avanzadas` text domain loads before any translated strings run (fixes `_load_textdomain_just_in_time` doing work too early).

= 2.2.1 =
* Plugin Check compliance: resolved all NonceVerification, EscapeOutput, PrefixAllGlobals, and SQL prepared statement warnings.
* i18n: all gettext msgids now use English; text domain aligned with slug (pezweb-ofertas-avanzadas).
* Build: composer.json bundled with vendor/; hidden files and dev metadata excluded from ZIP.

= 2.1.5 =
* Remove all artificial feature limits and locked strategies to comply with WordPress.org Plugin Directory Guidelines.
* Lite build no longer includes Pro-only strategy references, upgrade URLs, or campaign count restrictions.

= 2.1.4 =
* Resolve all Plugin Check warnings: wp_unslash on all POST reads, absint for IDs, object cache for direct DB queries, remove deprecated load_plugin_textdomain.
* Build: Lite ZIP filename no longer includes -lite suffix (matches wp.org slug).

= 2.1.3 =
* Plugin URI now differs from Author URI (WordPress.org requirement).
* Lite no longer calls deactivate_plugins(); skips initialization when Pro is active and shows an admin notice instead.

= 2.1.2 =
* WordPress.org: uninstall handler, ZIP verification in build, readme external services; deploy option to keep current version; admin assets and shortcode hygiene.

= 2.1.1 =
* WordPress.org readiness: readme stable tag, external services disclosure, English plugin header description.
* Pro/Lite conflict: Pro correctly deactivates the Lite package when both are installed.
* i18n: Pro strategy labels use literal translatable strings; product expiry field and storefront notice are translatable.
* Styles: product expiry admin/frontend use enqueued CSS (no inline styles); admin Tailwind utilities built locally (no `cdn.tailwindcss.com`).

= 2.0.18 =
* Readme and branding aligned with PW - Ofertas Avanzadas; Spanish (es_ES) translation; filterable Pro upgrade URL.

== Upgrade Notice ==

= 2.26.4 =
* **Fix:** remove strict `array` type hint from `ProductPriceHandler::filterVariationPricesArray()` to prevent fatal TypeError when WooCommerce passes a string instead of an array in admin product lists.
* **Meta:** `Tested up to` header bumped to WordPress **7.0**.

= 2.26.3 =
Important hotfix: installs the missing pricing handler files that caused a fatal error on sites updating to 2.26.0 from WordPress.org.

= 2.26.0 =
Recommended update: three-strategy Lite catalogue, wizard and audience picker improvements, safer stacking default, `pw/backend-ui` **1.4.7**, admin fatal-error fix for older Backend UI bundles, cleaner product pages when there's no product photo, improved admin CSS load order, and expanded Spanish translations.

= 2.2.4 =
Important hotfix for the campaign wizard: the Lite package now includes the missing sanitizer file, and admin Tailwind loads after BackendUI's core styles so the dashboard and wizard stay readable.

= 2.2.1 =
Remove all artificial feature limits and locked strategies to comply with WordPress.org guidelines.

= 2.1.1 =
Recommended update for WordPress.org metadata, translations, and admin/frontend styling.
