=== Memory Match Marketing Game for WooCommerce ===
Contributors:      tarekzaher
Tags:              woocommerce, coupons, gamification, interactive, block
Requires at least: 6.7
Tested up to:      7.0
Requires PHP:      7.4
Stable tag:        1.0.0
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

A customizable memory match game block that rewards customers with a WooCommerce coupon when they win.

== Description ==

**Memory Match Marketing Game for WooCommerce** adds an interactive mini-game to your WooCommerce store. Instead of handing out discount codes freely, customers get to earn them creating a fun, memorable experience that keeps them engaged with your brand.

Drop the Memory Match block anywhere on your site using the WordPress block editor. It's a classic card-flipping memory game: when a customer matches all the pairs, they're rewarded with a coupon code they can copy and use at checkout. Perfect for product launches, seasonal sales, or any campaign where you want to create a moment.

= Key features =

* **Fully configurable from the block editor** — upload your own card images for up to six pairs
* **WooCommerce coupon integration** — attach any existing coupon, or create a new coupon right from the block editor with your chosen discount settings
* **Confetti on win** — a satisfying celebration when the customer succeeds
* **Copyable coupon code** — the reward code is displayed with a one-click copy button
* **Color controls** — style the game to match your brand
* **InnerBlocks support** — add any WordPress blocks to the win screen (buttons, links, forms, etc.)
* **Stage preview in editor** — toggle between Pre-Start, Playing, and Result views while editing so you can style every state without leaving the page
* **Built with the Interactivity API** — fast, lightweight frontend with no jQuery dependency

= Use cases =

* Reduce cart abandonment by enticing customers with a fun game and discount
* Limited-time sale campaigns that feel special
* Encourage newsletter signups by pairing a game reward with an opt-in form on the win screen
* Product launches where you want to generate buzz

== Source Code & Build Process ==

The JavaScript files in the `build/` directory are compiled. The complete, human-readable source code is included in this plugin's `src/` directory.

The plugin is built with [@wordpress/scripts](https://www.npmjs.com/package/@wordpress/scripts) (webpack). To build it from source:

1. Install [Node.js](https://nodejs.org/) (v20 or later).
2. From the plugin root directory, run `npm install`.
3. Run `npm run build` to compile `src/` into `build/`, or `npm run start` for a development build with file watching.

The plugin bundles the [canvas-confetti](https://github.com/catdad/canvas-confetti) library (MIT licensed); its source code is available at https://github.com/catdad/canvas-confetti.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`, or install it directly from the WordPress plugin screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Make sure WooCommerce is installed and activated.
4. In the block editor, search for **Memory Match** and add the block to any page or post.
5. Select an existing coupon from the sidebar panel (or create a new one from the editor), upload card images, customise the colors, and publish.

== Frequently Asked Questions ==

= Does this require WooCommerce? =

Yes. The plugin integrates directly with WooCommerce to attach real discount codes to the game reward.

= Can I use my own existing coupons? =

Yes. The block has a coupon selector in the sidebar where you can pick any coupon already created in WooCommerce.

= Can the plugin create a coupon for me? =

Yes — choose the "Create a new coupon" mode in the block sidebar, set the discount type, amount, expiry, and other options, then click **Create Coupon**. A WooCommerce coupon with a random code is created right there in the editor and shown to every player who wins the game. Each customer can redeem it once. You can click **Create New Coupon** at any time to generate a fresh one.

= Where do I edit the card images? =

Switch to the **Playing** stage using the toolbar dropdown while editing the block. Each card slot has an image picker you can click to upload or select from the media library.

= Can I customise what players see when they win? =

Yes. You can add any WordPress blocks (buttons, links, images, forms) to the win screen using InnerBlocks.

= Is this compatible with full-site editing (FSE) themes? =

Yes. The block works in the site editor and the classic post/page editor.

== Screenshots ==

1. Memory Match block on the frontend — cards flip to reveal images, and matching all pairs reveals the coupon.
2. Win screen with copyable coupon code and confetti celebration.
3. Block editor sidebar — coupon settings, color controls, and stage preview toggle.

== Changelog ==

= 1.0.0 =
* Initial release: Memory Match game block
* WooCommerce coupon integration — attach an existing coupon, or create a new one from the block editor
* New coupons are created in the editor by an authenticated admin; the frontend exposes no public REST endpoint
* Confetti on win, copyable coupon code, InnerBlocks support on win screen
* Stage preview toolbar (Pre-Start / Playing / Result) in the editor
