﻿=== Onlinefotka Order Status Manager for WooCommerce ===
Contributors: onlinefotka
Tags: woocommerce, order status, custom status, order management, email notifications
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
WC requires at least: 7.0
WC tested up to: 9.9
Stable tag: 1.3.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create and manage custom WooCommerce order statuses with email notifications, shortcodes, auto-transitions, and a modern admin interface.

== Description ==

**Custom Order Status Manager by Onlinefotka** gives you full control over your order workflow. Create unlimited custom statuses, configure native WooCommerce email notifications with a powerful shortcode system, set up automatic status transitions, and let your customers track their order progress visually.

Built from the ground up with HPOS (High Performance Order Storage) compatibility and a clean, modern admin interface.

=== Custom Order Statuses ===

* Create unlimited custom order statuses
* Set status name, slug, color, and Lucide icon
* Drag-and-drop reordering
* Define allowed next statuses (workflow control)
* Include or exclude from WooCommerce reports
* Enable as bulk action in the orders list
* Configurable payment status: Paid / Unpaid / Needs Payment
* Orders remain editable in custom statuses by default
* Colored status badge in WooCommerce admin order list
* **Built-in WooCommerce statuses** (Pending, Processing, On Hold, Completed, Cancelled, Refunded, Failed, Draft) appear in the list too — customise their color, icon, name and auto-notes; slug and delete are protected

=== Email Notifications with Shortcodes ===

* Full integration with the WooCommerce email system
* Customer and Admin email types
* Trigger emails on status change or new order placement
* CC / BCC support for admin emails
* **Powerful shortcode system** — insert live order data anywhere in Subject, Heading, or Body:
  * `[order_number]`, `[order_date]`, `[order_status]`, `[order_total]`
  * `[order_items]` — automatic styled product table with totals
  * `[customer_name]`, `[customer_first_name]`, `[customer_email]`, `[customer_phone]`
  * `[billing_address]`, `[shipping_address]`
  * `[payment_method]`, `[order_notes]`, `[view_order_link]`
  * `[site_title]`, `[site_url]`, `[admin_email]`
* Shortcode helper panel in the editor — click any shortcode to insert at cursor
* Test email button — send a preview to your admin email with one click
* Standard WooCommerce email wrapper (compatible with email customizer plugins)

=== Auto Order Notes ===

* Automatically add a private order note when an order enters a specific status

=== Auto-Transition ===

* Automatically move orders to another status after X hours
* Global on/off switch (disabled by default for safety)
* Per-status configuration
* WP Cron powered — respects the current order status (no overwrite on manual change)

=== Customer Progress Tracker ===

* Visual progress bar on My Account → View Order page
* Shows completed, active, and upcoming statuses in order
* Can be toggled on/off in Settings

=== Quick Status Change ===

* Change order status directly from the orders list via AJAX
* No page reload required
* Respects allowed next-status workflow

=== Export / Import ===

* Export all custom statuses as JSON
* Import on another site (skips duplicates by slug)

=== Dashboard Widget ===

* Order count per custom status directly on the WordPress dashboard

=== HPOS & Legacy Compatible ===

* Works with WooCommerce High Performance Order Storage (HPOS)
* Works with traditional post-based orders
* Declared compatible with WooCommerce cart/checkout blocks

=== Requirements ===

* WordPress 6.0 or higher
* WooCommerce 7.0 or higher
* PHP 8.0 or higher

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install via **Plugins → Add New** in your WordPress admin
2. Activate the plugin through the **Plugins** screen
3. Navigate to **WooCommerce → Order Statuses** to configure your first custom status

== Frequently Asked Questions ==

= Will my custom statuses work with HPOS? =

Yes. The plugin is fully compatible with WooCommerce High Performance Order Storage (HPOS / custom_order_tables).

= Are orders editable in custom statuses? =

Yes. By default all statuses — including built-in WooCommerce statuses like Processing and On Hold — allow order editing through OCSM. You can toggle the "Order is editable" option per-status in the Options panel.

= Does this use WooCommerce native emails? =

Yes. All email notifications are registered as standard WooCommerce email classes. They appear in WooCommerce → Settings → Emails and are compatible with popular email customizer plugins.

= How do shortcodes work? =

Shortcodes like `[order_number]` or `[customer_first_name]` can be placed anywhere in the email Subject, Heading, or Body. They are replaced with live order data at the moment the email is sent. The shortcode helper panel in the editor lets you click any shortcode to insert it without typing.

= What does [order_items] output? =

`[order_items]` renders a styled HTML table containing all ordered products, quantities, and prices — plus a total row. The header color automatically matches your WooCommerce email accent color.

= What happens if I delete a custom status? =

All orders in that status are automatically moved to the fallback status (configurable in Settings, default: On Hold).

= Can I import statuses from another site? =

Yes. Use the Export button in the Status list to download a JSON file. Then use Import on the target site — existing slugs are skipped to avoid duplicates.

= How does auto-transition work? =

When an order enters a status that has auto-transition configured (and the global switch is enabled), a WP Cron event is scheduled. After the set number of hours, the order moves to the target status — but only if it is still in the original status. Manual status changes are never overridden.

= How long can a status slug be? =

The slug (without the `wc-` prefix) can be up to 47 characters. The full key stored in the database (`wc-` + slug) must not exceed 50 characters. The editor enforces this limit automatically.

= Is the plugin compatible with WooCommerce Blocks / cart and checkout blocks? =

Yes. Block compatibility is declared via the WooCommerce FeaturesUtil API.

== Screenshots ==

1. Order Statuses list — main plugin page showing the statuses tab with Export, Import, and Add Status buttons
2. Email Notifications — email tab with the Add Email button and empty-state prompt
3. Settings — auto-transition global toggle, fallback status selector, and customer progress tracker option
4. Add / Edit Status — full status form with name, description, color picker, icon picker, payment status, workflow next-statuses, and bulk action options
5. Add / Edit Email — email name, description, email type selector, and trigger status checkboxes (choose which status change fires the email)
6. Email editor — subject line, heading, shortcode helper panel with click-to-insert tags, and the rich-text body editor

== Changelog ==

= 1.3.4 =
* New: WooCommerce built-in order statuses (Pending, Processing, On Hold, Completed, Cancelled, Refunded, Failed, Draft) now appear in the OCSM status list with a WC badge
* New: built-in statuses can be customised (color, icon, name, auto-note, next statuses) — slug is locked and deletion is blocked
* New: orders in built-in WC statuses (e.g. Processing) are now editable by default via the OCSM "Order is editable" setting
* DB migration 1.3.0: adds `is_builtin` column and seeds the 8 built-in statuses automatically on upgrade

= 1.3.3 =
* New: Our Plugins sidebar with support links shown on all plugin admin pages
* Fix: default value for "Include order details" was incorrectly false for pre-migration emails — now defaults to true
* Fix: WC_Email class guard added before loading email class to prevent fatal errors in edge-case load orders
* Fix: POST check now runs before GET action check in admin forms to prevent double-processing

= 1.3.2 =
* Fix: emails were sent as plain text instead of HTML (email_type not initialized after parent::__construct())
* Fix: inline styles stripped from email body on save and at send time (wp_kses safecss_filter_attr() interference)

= 1.3.1 =
* New: Czech (cs_CZ), German (de_DE), and Hungarian (hu_HU) translations

= 1.3.0 =
* New: email shortcode system — use `[order_number]`, `[customer_name]`, `[order_items]` etc. in Subject, Heading, and Body
* New: shortcode helper panel in the email editor — click any shortcode to insert at cursor position
* New: `[order_items]` renders a complete styled product table with totals
* New: colored status badges in WooCommerce admin order list (uses configured status color)
* New: test email button in email editor — sends a preview to the admin email using the most recent order
* New: clear error message when the status slug is too long (instead of a silent failure)
* New: order count per status in the status list (clickable, links to filtered order list)
* New: Slovak (sk_SK) translations for all strings
* Improved: slug input enforces the 47-character maximum in the browser
* Fix: Lucide Icons bundled locally — removed external CDN dependency

= 1.2.0 =
* Fix: order status reverting to Pending when the status slug exceeded 17 characters (WooCommerce stores slugs with a `wc-` prefix — `wp_wc_orders.status` was VARCHAR(20) and silently truncated longer slugs)
* DB migration: widens `wp_wc_orders.status` to VARCHAR(50) and repairs any already-truncated values
* DB migration: widens `wp_posts.post_status` to VARCHAR(50) for legacy (non-HPOS) installs
* New: server-side slug length validation in `save_status()` prevents saving slugs that would exceed the column width

= 1.1.0 =
* New: "Include order details table" toggle per email notification — disable to send only your custom message without the order summary appended
* DB migration: adds `include_order_details` column to the emails table

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.3.4 =
Adds WooCommerce built-in statuses to the OCSM list. A database migration runs automatically on upgrade (adds `is_builtin` column and seeds 8 WC statuses). No data loss — safe to update.

= 1.3.3 =
Minor fixes and UI improvements. No database changes required.

= 1.3.2 =
Important bug fix: emails were sent as plain text instead of HTML. Update recommended for all users using custom email notifications.

= 1.3.1 =
Adds Czech, German, and Hungarian translations. No database changes required.

= 1.3.0 =
Adds a full shortcode system for email notifications and bundles Lucide Icons locally. No database changes required — safe to update.

= 1.2.0 =
Contains an important database migration that widens the order status column to prevent status-revert issues with long slugs. The migration runs automatically on activation/update.
