=== WPHostee Competitions for WooCommerce ===
Contributors: baicu4design
Tags: competitions, giveaways, prize draw, raffle, woocommerce
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.9.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: woocommerce

Sell prize competition tickets through WooCommerce, with race-condition-safe ticket allocation and an auditable random draw.

== Description ==

WPHostee Competitions turns any WooCommerce store into a prize competition platform. Customers buy tickets like a normal product; you run a fair, provably random draw whenever a competition closes.

Built with three things in mind: **no overselling**, **no unfair draws**, and **a full audit trail** of everything that happens.

= Core features (free) =

* A dedicated Competition product type - sells and checks out exactly like any other WooCommerce product
* Race-condition-safe ticket allocation - two customers can never be issued the same ticket number, even buying the last few tickets at the exact same moment
* Sequential ticket numbering, formatted with configurable leading zeros
* A cryptographically random draw (never a predictable `rand()`), with the exact eligible-entry list hashed and logged for later verification
* Built-in support for the skill-question requirement UK prize competitions need to stay legally distinct from a lottery
* Full admin toolkit: Dashboard, All Competitions, Entries, Ticket Reservations, Draws, and Winners (claim status, tracking number, notes, and a fully-audited Void & Redraw)
* Customer-facing "My Competitions" tab in My Account, plus countdown, progress-bar, and competition-facts shortcodes
* Run as many competitions at once as you like, all sequential-numbered - the free tier is genuinely usable on its own, not a crippled trial
* Compatible with WooCommerce High-Performance Order Storage (HPOS)

= WPHostee Competitions Pro =

A separate, paid companion plugin unlocks: Random (Lucky Dip) ticket assignment and manual ticket selection, a Free Postal Entry route, per-customer/order/day entry limits, Reports with CSV export, a full Audit Log viewer, a REST API, Elementor widgets, and a winner publicity/consent workflow with automatic emails. Free works completely on its own without it - Pro is entirely optional.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/wphostee-competitions`, or install directly through the WordPress Plugins screen.
2. Make sure WooCommerce is installed and active - this plugin requires it.
3. Activate the plugin through the "Plugins" screen in WordPress.
4. Go to Competitions → Settings to set your ticket reservation timeout and default numbering options.
5. Create a competition: add a new WooCommerce product, set its Product type to "Competition," and fill in the Competition tab.

== Frequently Asked Questions ==

= Do I need WooCommerce for this to work? =

Yes. Competitions are a WooCommerce product type, so they use your existing cart, checkout, payment gateways, and order emails.

= Can two customers ever be sold the same ticket number? =

No. Ticket allocation is protected by a database row lock plus a unique constraint at the database level, so even the very last ticket in a competition can't be double-sold under simultaneous purchases.

= How is the draw kept fair? =

The draw uses PHP's cryptographically secure random number generator, never a predictable function. The exact list of eligible tickets is hashed and recorded in the Audit Log at the moment of the draw, so the result can be independently checked afterwards.

= Can I run more than one competition at a time? =

Yes, the free version has no limit on how many competitions can be active at once.

= Does this delete customer data if I uninstall the plugin? =

No, not by default. Competition, entry, and winner data is kept even if you remove the plugin, unless you explicitly opt in to full deletion under Competitions → Settings → Privacy.

= Is this compatible with High-Performance Order Storage (HPOS)? =

Yes, the plugin declares and works correctly with HPOS.

== Screenshots ==

1. Competitions Dashboard, with at-a-glance status across every competition
2. The Competition tab on a WooCommerce product
3. The Winners screen, with claim tracking and Void & Redraw
4. A competition's customer-facing entry page

== Changelog ==

= 1.9.5 =
* Fixed: when choosing specific ticket numbers (Pro), picking a second or third ticket did nothing unless the quantity box had already been increased to match first. The quantity (and running total) now updates automatically to match however many tickets are picked, up to the competition's own per-order limit.

= 1.9.4 =
* The competition's short description (set on the product's "short description" field, same as any other WooCommerce product) now shows directly under the title, instead of further down the page below the price and ticket details.
* The upgrade link shown in the free plugin now points straight to this plugin's own Pro store page.

= 1.9.3 =
* The price shown on a competition now makes clear it's the price per ticket, and the running total while choosing quantity now makes clear it's the total for the tickets selected.
* Added explanatory tooltips to the "minimum tickets", "maximum tickets" and "one winner" facts shown on a competition page.
* Removed the standalone "This is the price for 1 ticket" note, now covered by the price label above.
* Fixed: WooCommerce's own default "Add to basket"-style button could appear a second time underneath this plugin's own "Enter Competition" button on the Shop page grid, depending on the active theme. Suppressed at the WooCommerce level so it can't reappear regardless of theme.
* Fixed: on themes that build the Shop page out of separate WooCommerce blocks (e.g. Twenty Twenty-Five), the price could be shown out of place below the "Enter Competition" button instead of above it like every other product.

= 1.9.1 =
* WordPress.org Plugin Check compliance pass: fixed every flagged error and warning, including proper escaping in a handful of admin/shortcode outputs, a missing translators comment, corrected escaping in the plain-text email templates, normalised corrupted line endings in several files, and removed a now-unnecessary load_plugin_textdomain() call (WordPress.org loads translations for hosted plugins automatically). No functional changes.

= 1.9.0 =
* Removed the "one active competition at a time" limit - run as many simultaneous competitions as you like, free of charge.
* Random (Lucky Dip) ticket assignment is now implemented entirely by the separate Pro companion plugin rather than being built into this plugin and merely gated - this plugin only ever assigns tickets sequentially on its own.

= 1.8.0 =
* WordPress.org review housekeeping: bumped Tested up to, renamed the text domain to match the assigned plugin slug, replaced a disabled admin checkbox with a plain-text note, escaped a shortcode's filter-provided output, made the Winners claim-status labels genuinely translatable, added a missing nonce check on the ticket-reservation add-to-cart flow, sanitized data passed into two extensibility filters, and moved two remaining inline admin scripts/styles to proper wp_enqueue_* calls.

= 1.7.1 =
* The author credit shown on the Plugins screen now reads "Catalin Baicu @ WPHostee", with only "WPHostee" linked.

= 1.7.0 =
* Renamed the plugin's internal database tables and settings keys from the too-short "pob_" prefix (a leftover from this plugin's earlier life as a single-client build) to "wphc_", per WordPress.org plugin review requirements. Existing data migrates automatically and safely on update - no action needed. Old shortcode names ([pob_competitions] etc.) keep working indefinitely as aliases, so no existing page content needs to change.

= 1.6.1 =
* Fixed: the maximum-tickets-per-order limit was only enforced on the product page - the Basket page's own quantity control had no idea it existed, letting a customer increase quantity past it after adding to basket. Now enforced by WooCommerce itself everywhere a quantity can be changed.

= 1.6.0 =
* Fixed: entries could stay stuck showing "pending" forever for manual payment methods (Bank Transfer/BACS, Cheque), even after the order was correctly marked Processing/Completed - WooCommerce doesn't fire the hook we relied on for a manual admin status change, only for gateways that confirm payment automatically.
* Added a "Payment Sync" tool on Settings that safely re-checks and fixes any entries left behind by the above, for existing orders.

= 1.5.1 =
* Fixed: the "Live"/"Closed" countdown badge could show both at once on themes that don't reset the HTML `hidden` attribute, since our own CSS wasn't respecting it.

= 1.5.0 =
* Each winner card on the admin Winners screen now shows a 115x115 round profile photo, always visible regardless of collapsed/expanded state - the customer's account avatar by default (WPHostee Competitions Pro can substitute a photo uploaded specifically for the public winners list).

= 1.4.0 =
* The admin Winners screen now shows collapsible cards (each starts collapsed, click to expand/collapse, plus "Expand all"/"Collapse all"), filters by competition, month, year, and city, and paginates at 10 winners per page - built for stores with large numbers of winners.

= 1.3.0 =
* Fixed: a mandatory competition question now actually requires the *correct* answer to proceed to checkout - previously any selected answer was accepted, only a blank answer was blocked.
* Added help tooltips explaining "Maximum tickets," "Minimum tickets," and every field in the Competition Question section.

= 1.2.0 =
* Added help tooltips explaining "When sold out," "Starting ticket number," "Ticket assignment," and "Manual ticket selection" on the Competition tab.

= 1.1.0 =
* New "Competition Rules" tab on the product page - per-competition, supports plain text, HTML, or shortcodes, only shown when rules text is entered.
* The "Enter Competition" button, quantity selector, and total price now sit inline on the same row.
* Relabelled "Related products" to "Other Related Competitions" on competition product pages.

= 1.0.3 =
* Fixed the admin menu icon rendering oversized in the sidebar.

= 1.0.2 =
* New custom admin menu icon.

= 1.0.1 =
* Updated the "Upgrade to Pro" link destination.

= 1.0.0 =
* Initial public release.

== Upgrade Notice ==

= 1.9.0 =
Removes the one-competition-at-a-time limit for everyone. If you also run WPHostee Competitions Pro, update it to 1.4.0+ at the same time - older Pro versions expect the old behavior, temporarily bringing back the limit until both are updated.

= 1.7.0 =
Internal database rename (safe, automatic, no data loss). If you also run WPHostee Competitions Pro, update both plugins together in the same maintenance window - Pro reads the same renamed tables directly, so updating only one at a time can cause brief errors until both are current.

= 1.6.0 =
Fixes entries staying stuck as "pending" for Bank Transfer/BACS or Cheque orders even after you mark them paid. After updating, visit Competitions -> Settings and click "Resync entries with paid orders" once to fix any orders already affected.

= 1.3.0 =
Fixes a checkout bug: a mandatory competition question now correctly requires the right answer, not just any answer. If you rely on the competition question for legal compliance, check your competitions still enforce it as expected after updating.

= 1.0.3 =
Fixes the admin menu icon showing oversized in the sidebar. No action needed.

= 1.0.1 =
Minor update to the Pro upgrade link. No action needed.
