=== PromoTimer – Flash Sale Scheduler for WooCommerce ===
Contributors: alin
Donate link: https://webdesign-profesional.com/promo-timer/
Tags: woocommerce, sale, countdown, promotions, flash sale
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Schedule WooCommerce sale prices with start/end date + time, show a live countdown timer, and display customizable promo messages.

== Description ==

**PromoTimer** lets you plan **time-boxed promotions** for WooCommerce products with **start/end date and time**, display a **live countdown** on the product page, and customize all **texts, emojis, and colors**.

Works for **simple products** and **product variations** — each variation can be scheduled **independently**.

**Perfect for:** flash sales, limited-time offers, seasonal discounts, and product launches.

**Highlights**
- 🕒 Schedule sales precisely: **start/end date + hour:minute**
- 🔥 Pre-promo message: *"Promotion starts on DATE at TIME"*
- ⏳ Live countdown during promo: *"Hurry up! Promotion ends in: 12:02:45"*
- 💸 Under-price message during promo: *"Take advantage! This product is on promotion."*
- 🧼 Auto-cleanup after expiry: removes promo meta and resets sale price
- 🎯 Full support for **variable products** (per-variation scheduling)
- 🎨 Admin settings to customize **texts**, **emoji**, and **colors**
- 🌍 Fully translatable (.pot included)
- 🧰 Clean architecture, no template overrides

> **Requires WooCommerce** to be active.

---

### 🚀 PRO Version Available

Looking for more power? **PromoTimer PRO** adds:

- 🔥 **Bulk Promotions by Category** — apply discounts to entire categories at once (% or fixed amount)
- 📋 **Campaigns Manager** — manage all your promotions in one table with name, category, dates, status
- 📊 **Admin Product List Column** — see active/scheduled promotions directly from the Products list
- ⚡ **Batch Processing** — handles large stores without timeouts (20 products per batch)

👉 [Get PromoTimer PRO](https://webdesign-profesional.com/promo-timer/)

---

== Features ==

- Schedule sale prices with **date + time** (start and end)
- Show **pre-promo** notice with start date/time
- Show **countdown** and **under-price** promo message while active
- Countdown disappears automatically when promo ends and **resets sale price**
- Works with **simple** and **variable** products (independent per variation)
- **Admin settings page**: customize emoji, colors, all texts (placeholders supported)
- **Promo badge** in shop/category/archive pages
- **Cache compatibility**: LiteSpeed, WP Rocket, W3TC, WP Super Cache and more
- **Internationalization ready** (`/languages/promo-timer.pot`)

== Screenshots ==

1. Plugin settings page — customize emoji, colors and text messages
2. Frontend product page — countdown timer with Promo badge in action

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install the ZIP via **Plugins → Add New**.
2. Activate **PromoTimer** from **Plugins**.
3. Make sure **WooCommerce** is active.
4. Go to **WooCommerce → PromoTimer** to customize emoji, colors, and texts.
5. Edit a product:
   - **Simple products**: Product data → General → Pricing → set Promo Start/End Date and Time
   - **Variable products**: Variations tab → set the same fields per variation

== Frequently Asked Questions ==

= Does it require WooCommerce? =
Yes. The plugin hooks into WooCommerce product/variation edit screens and the single product template.

= Will it work with variable products? =
Yes. Each variation has its **own** start/end date and time. The frontend countdown and messages update when a variation is selected.

= Does it change my theme templates? =
No template overrides. It uses standard WooCommerce hooks only.

= Can I customize the texts and emoji? =
Yes. Go to **WooCommerce → PromoTimer**. You can customize the emoji, main color, and 3 text messages (before promo, during promo, under price). Placeholders `{date}` and `{time}` are supported.

= Is it translatable? =
Yes. Fully internationalized with a `.pot` file included in `/languages`. Use Loco Translate or Poedit.

= What happens when the promotion ends? =
A WP-Cron task runs hourly to clean expired promotions: removes promo meta fields, resets the WooCommerce sale price, and clears cache. The countdown also disappears automatically on the frontend.

= Is there a PRO version? =
Yes! **PromoTimer PRO** adds bulk promotions by category, a campaigns manager, and an admin product list column. [Learn more here](https://webdesign-profesional.com/promo-timer/).

== Changelog ==

= 1.0.6 =
* Tested with WordPress 7.0

= 1.0.5 =
* Fix: PHP Fatal Error on LiteSpeed Cache servers — removed static call to LiteSpeed\Purge::purge_post() which is not a static method in newer LiteSpeed versions; replaced with do_action hook for compatibility with all versions
* Fix: Emoji icon could not be saved on servers where MySQL uses utf8 (3-byte) charset — replaced text input with a dropdown selector; emoji keys are stored as ASCII identifiers and mapped to HTML entities at display time
* Fix: Settings form failed silently when emoji field contained a 4-byte UTF-8 character, preventing all other settings from saving
* Fix: Cleanup cron skipped products with empty End Time field; now defaults to 23:59 matching frontend behavior
* Improvement: Emoji now displays correctly in all contexts — single product page, shop loop, product variations, and page builder widgets (Elementor, Divi, Gutenberg etc.)
* Improvement: Date format in promo messages now follows WordPress Settings → General → Date Format instead of hardcoded Romanian format

= 1.0.4 =
* Fix: Sale price was recreated in database after cleanup cron ran
* Fix: Price not fully reset to regular price after promotion expiry

= 1.0.3 =
* Fix: After promotion expiry, product price was not displaying correctly on the product page
* Fix: Sale price was not fully removed from database after cleanup cron ran

= 1.0.2 =
* Fix: Sale price was showing on variable product parent even when promotion was not active
* Fix: Sale price was incorrectly applied in cart and checkout before campaign start time
* Fix: WooCommerce price cache was not cleared after promotion expiry
* Fix: Countdown was displaying "0d" and "0h" — now hidden automatically when value is zero
* Fix: Incorrect timezone on servers running UTC — replaced time() with wp_timezone()
* Fix: Product page was showing cached content after promotion expiry on LiteSpeed/WP Rocket/W3TC
* New: Promo badge now appears in shop/category/archive pages
* New: "Campaign starts on..." message now also displayed in product listing pages
* CSS: Badge forced onto new line regardless of price width

= 1.0.1 =
* Initial release on WordPress.org