=== PluginCity First Order Discount for WooCommerce ===
Contributors: plugincitywp
Tags: woocommerce, discount, first order, welcome discount, new customer
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 10.0
WC tested up to: 11.2

Give a customer a discount on their first order only, with no code to share. It is checked against your real order history, and again when they pay.

== Description ==

A welcome discount only works if a customer can have it once. A shared code gets passed round, and a code that is checked only in the basket can be dodged by changing the email address at checkout.

This plugin has no code to share. A customer on their first order is given the discount automatically, and it is taken away again if the order turns out not to be their first. Typing a code in does nothing: the discount cannot be asked for, only earned.

= How a new customer is recognised =

* By their account if they are logged in, and by their email address if they are not
* Capital letters and plus-tags are ignored on every address, and dots are ignored on Gmail and Googlemail addresses only, so `jo+shop@gmail.com` and `J.O@googlemail.com` are the same person
* Refunded and on-hold orders count as earlier orders. Unpaid, failed and cancelled ones do not
* The check is made in the basket and again at the moment the order is placed, so changing the email address at checkout, or paying in two tabs at once, does not get round it
* Orders placed before you installed the plugin are read in the background, and until that has finished your orders are searched directly, so an existing customer is never mistaken for a new one

= What you get =

* A percentage or a fixed amount off, with an optional minimum basket
* A choice to leave items already on sale out
* A welcome popup that tells new visitors about the offer, as a pop-up or a slide-in, in your own wording and colours
* The popup appears after a few seconds, when a visitor scrolls down the page or moves to leave, once per visitor, and only to someone who could still be given the discount
* The popup is checked as it is shown, so it works behind a page cache and never promises more than the checkout gives
* A read-only `fodwc_offer_summary` filter that returns the current offer, for other plugins to read
* A name for the discount line that you choose
* What happens when the customer also has a coupon: use whichever is worth more, allow both, or use the welcome discount only
* The discount shown as a coupon-style discount, or as a fee line taking money off if your theme hides discounts
* Plain-words messages you can edit, shown in the basket and at checkout, and a shortcode, `[fodwc_message]`, to put the same message anywhere
* Works in both the block cart and checkout and the classic ones
* A Tools screen to check any customer, rebuild the order record, or mark someone as new again
* A First order box on each order showing what was decided
* Settings import and export
* High-Performance Order Storage compatibility
* Personal data export and erase support

The free version is permanent. It has no account, no key, and never contacts PluginCity.

Want to go further? [Pro](https://www.plugincity.net/plugins/first-order-discount-for-woocommerce) can limit the discount to certain products or categories, cap what one order can take off, offer more on bigger baskets, add free shipping or a free gift, recognise a returning customer by delivery address or phone number, turn away disposable email addresses, and restrict the offer by role or date. For the popup it adds more styles, rules for pages, baskets and where a visitor came from, a second headline to test, and counts of how it does.

Pro is a separate paid version sold and distributed by PluginCity. It is not included in this plugin and is not downloaded or installed by it, and nothing described above depends on it. Your settings carry over if you buy it.

== Installation ==

WooCommerce must be installed and active first.

1. In WordPress, go to **Plugins → Add New**.
2. Search for **First Order Discount for WooCommerce**.
3. Click **Install Now**, then **Activate**.
4. Go to **WooCommerce → First Order Discount**, or click **Settings** on the Plugins screen.

Installing from a downloaded ZIP instead: go to **Plugins → Add New → Upload Plugin**, choose the ZIP file, and click **Install Now**. Leave the ZIP as it is; there is no need to unzip it.

== Configuration ==

1. Choose a percentage or a fixed amount, and enter it.
2. Set a minimum basket if you want one, and decide whether sale items are left out.
3. Decide what happens when a customer also has a coupon.
4. Tick **Give the welcome discount** and save.

== Frequently Asked Questions ==

= Does it work with the block cart and checkout? =

Yes, and with the classic ones. On the block checkout a customer who turns out not to be new is told in plain words, and the total is refreshed without the discount, so nothing is charged that they did not agree to.

= Can a customer type a code to get the discount? =

No. There is no code to share. The discount is applied by the plugin when the customer is eligible, and nothing is applied when they are not, whatever they type.

= Can someone get it twice by using another email address? =

Not with the same account, and not by changing the capitals, adding a plus-tag or adding dots in a Gmail address. A customer who simply uses a completely different mailbox and a different account looks like a new customer, and that is true of every offer that does not ask for more identification. Pro can also match on delivery address and phone number.

= What counts as an earlier order? =

Paid, on-hold, completed and refunded orders count. Unpaid orders count only if you tick the box for it. A subscription renewal never makes someone count as having ordered, and an order created by hand in the admin is never given the discount but does count.

= What happens to the record of who has ordered? =

It keeps only scrambled codes made with a secret key stored on your site, never the addresses themselves. It is kept when you deactivate or delete the plugin, so the discount cannot be given twice if you reinstall. You can erase a customer through WordPress's personal data tools.

= Does the popup give out a code? =

No, because the discount has no code. The button, Claim my discount, confirms that the discount will come off at checkout for a first order, and offers a link to the shop. If the customer turns out not to be new, the checkout says so, as it always did.

= Who is shown the popup, and does it work with a caching plugin? =

It is switched on by you and is off until then. It is never drawn on the cart, checkout or account pages, and not while the discount is off or has ended. The page carries the same markup for everyone, so a cache can store it. Before it opens, the browser asks your shop whether this visitor could still be given the discount, and a customer who has ordered before is not shown it. The popup is shown once, and again after the number of days you choose. Storing that takes one note in the browser's own storage, and no cookie.

= Does it slow my shop down? =

No. A customer is looked up by an indexed column. While your older orders are still being read in, a search of the orders themselves fills the gap.

= Does it work with High-Performance Order Storage? =

Yes. Orders are only read and written through WooCommerce, so either storage works.

= What happens if I deactivate WooCommerce? =

The plugin steps aside and shows a notice. It does not fatally error, and your settings are waiting when WooCommerce comes back.

= Do I need an account or a licence? =

No. It is free to use for as long as you like, needs no key, and never contacts PluginCity.

== Screenshots ==

1. The welcome popup as a first-time visitor sees it. The amount, the minimum spend and what is left out come from the discount settings, and there is no code.
2. The same offer as a slide-in, which sits in the corner and leaves the page readable behind it.
3. On a phone, the popup (left) and the slide-in (right) fit the screen and stay easy to close.
4. Welcome popup settings: a pop-up or a slide-in, shown after a delay, on scroll or when a visitor goes to leave, and how long before it comes back.
5. Popup wording and colours: your own heading, message and button, colours checked for contrast, and a preview on your shop.
6. The welcome discount itself: a percentage or a fixed amount, an optional minimum basket and sale items left out. The popup always repeats it.
7. A new customer's basket, with the welcome discount taken off automatically and no code to type.

== Changelog ==

= 1.1.1 =
* Tweak: the settings import reads the uploaded file through WordPress's own filesystem class. Every check on the upload is unchanged.
* Tweak: the description of how email addresses are matched is now exact: what is ignored is capital letters and plus-tags on every address, and dots on Gmail and Googlemail addresses only.

= 1.1.0 =
* New: a welcome popup, as a pop-up or a slide-in, that tells new visitors about the offer. It can appear after a delay, on scroll or when a visitor goes to leave, is shown once per visitor, and is never shown to a customer who has ordered before.
* New: it is drawn the same for everyone and checked as it opens, so it works behind page caches, and what it says always comes from the discount settings.
* New: the `fodwc_offer_summary` filter returns the current offer for other plugins to show.

= 1.0.0 =
* First public release.

== Upgrade Notice ==

= 1.1.1 =
A small maintenance release. Nothing changes in how the discount works and no settings need attention.

= 1.1.0 =
Adds a welcome popup for new visitors. It is off until you switch it on under WooCommerce, First Order Discount.
