=== SK Out Of Stock Notice ===
Contributors: svenkersten
Tags: woocommerce, out of stock, sold out, variations, stock notice
Requires at least: 6.1
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Clear notice on sold out WooCommerce products instead of greyed out options. Hides sold out sizes and links to alternatives.

== Description ==

Visitors often land on a sold out product straight from Google. All they see is greyed out options and a "Choose an option" dropdown, so they assume the shop is broken and send you an email. SK Out Of Stock Notice makes it obvious that the product is sold out and points them to alternatives, while the page keeps its place in Google.

**When a product is completely sold out** (for a variable product: when all variations are sold out):

* The whole order block disappears: options, quantity and the add to cart button.
* A notice takes its place, with a "View alternatives" button that links to the product's category.
* An optional banner on the product image, for example "Temporarily out of stock". Choose a diagonal banner, a straight band or a corner label (top left or top right).
* The product page stays online and indexable. No noindex, no 404, so it keeps its rankings for when the stock comes back.

**When only some options are sold out**, those options disappear from the dropdown instead of being greyed out. This also works with multiple attributes (such as size and colour): combinations that can no longer be ordered disappear.

**Per product** (Inventory tab) you can:

* turn the notice off for that product;
* choose between "Temporarily out of stock" and "Not coming back", each with its own default text;
* set your own banner and notice text (the general text is shown as a placeholder);
* choose where the alternatives button goes for that product: a product or a product category (type to search), or an address of your choice.

**Settings**

* All texts can be changed. Leave the button text empty to show no button.
* Choose where the alternatives button links to: the product category, the shop page or an address of your choice.
* See at a glance whether WooCommerce hides sold out products from your shop and categories, with a link to that setting.
* Colour scheme: Neutral (default), Follow my theme (uses the colour of your theme's buttons) or Custom colours for the banner and the notice.
* A small second line on the banner, for example "View the alternatives".
* Optionally grey out the product image so the banner stands out more. Off by default, so the image keeps its real colours.
* Hiding sold out options can be turned off.

**Where the alternatives button links to**

A product or category chosen in the Inventory tab of the product comes first. If that product is removed or sold out itself, or the category is empty, the general setting applies.

By default the product category, in this order:

1. The primary category set in Rank Math.
2. The primary category set in Yoast SEO.
3. The product's first category in alphabetical order.
4. The shop page.

**Theme compatibility**

The notice replaces the order block through WooCommerce's own add to cart action for each product type. It therefore also works with themes that place the order block outside the standard product summary, such as Flatsome with a custom product layout built in the UX Builder. The banner supports both the default WooCommerce gallery and Flatsome's gallery.

**Translations**

All texts on the product page are regular HTML, so translation plugins that translate the page (TranslatePress, Weglot, GTranslate) pick them up. For WPML and Polylang the plugin includes a `wpml-config.xml`, so the texts from the settings appear in String Translation.

The plugin makes no external requests and sets no cookies.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the plugin through Plugins > Add New > Upload Plugin, or unzip it to `wp-content/plugins/sk-out-of-stock-notice/`.
3. Activate the plugin.
4. Go to **Sven Kersten > Out of stock notice** to adjust the texts and colours.

== Frequently Asked Questions ==

= Does the product page disappear from Google? =

No. The page stays online and indexable. Only the order block is replaced by the notice.

= When does the notice appear on a variable product? =

When all variations are sold out. As long as one variation is in stock, the product can be ordered and only the sold out options are hidden.

= Can I use a different text for a product that will never come back? =

Yes. Set the product to "Not coming back" in the Inventory tab. It then uses the "not coming back" texts from the settings, or your own text for that product.

= The notice does not appear with my theme. =

The plugin hooks into WooCommerce's add to cart action, which every theme that uses the standard WooCommerce order form calls. If your theme builds its own order form without that action, the form is still hidden by a CSS fallback, but the notice may not be shown. Please get in touch so we can look at your theme.

= How do I disable the plugin without access to wp-admin? =

Rename the folder `wp-content/plugins/sk-out-of-stock-notice` (for example to `sk-out-of-stock-notice.disabled`) via FTP or SSH. WordPress then no longer loads the plugin.

= What is removed when I delete the plugin? =

The option `sk_oosn_settings` and the per product settings (`_sk_oosn_*` meta). WooCommerce and theme data are not touched.

== Screenshots ==

1. A sold out product: the order block is replaced by the notice, with a banner on the image.
2. A product where some sizes are sold out: only the available sizes are listed.
3. The settings page: texts, display options and colours.
4. Per product settings in the Inventory tab.

== Changelog ==

= 1.5.0 =
* Inventory tab: choose per product where the alternatives button goes: a product or a product category (type to search, using the WooCommerce search fields), or an address of your choice. Stored by ID, so a changed URL does not break the button. Falls back to the general setting when the chosen product is removed, unpublished or sold out, or the category is empty.

= 1.4.2 =
* Settings page: the "Sold out products in your shop" status is now one clear status line, a short explanation and a separate button to the WooCommerce setting.
* Inventory tab: an empty custom text field now shows the general text from the settings as a placeholder. It follows the chosen type of sold out, so you see what appears on the page when you leave the field empty.
* Inventory tab: the custom notice field is taller, so the whole general text fits.

= 1.4.1 =
* Settings page: consistent spacing between every field and its explanation (text fields, text areas, switches and choice cards).
* Inventory tab: the explanation of the custom texts now shows below the field, so the fields stay aligned in every admin theme.
* Banner style previews show normal case, matching the banner; capitals only with Custom colours.
* Shared SK admin shell 2.1.1.

= 1.4.0 =
* New calm default look: a light, slightly transparent banner with dark text in normal case and a small second line ("View the alternatives"), and a light grey notice. No signal colours, so it fits every shop. The alternatives button keeps your theme's button style.
* Colour scheme setting: Neutral (default), Follow my theme (lines in the colour of your buttons, measured from the button itself) or Custom colours. The colour fields only show for Custom colours.
* Existing sites: if you never changed the colours you get the new neutral look; if you did, you stay on Custom colours with your own colours.
* New installations start with the straight band.
* Fix: a long text on the diagonal banner could run outside the image.
* "Grey out product image" now uses a softer filter that keeps the colours of the product.

= 1.3.3 =
* Themes with their own product gallery slider (such as Kadence Shop Kit with Splide, or galleries built on Swiper, Slick or Flickity) now get the banner on each large slide, centred on the image, instead of on the whole gallery. Thumbnail rows are skipped.
* Pages with more than one product gallery (for example a separate gallery for mobile) get the banner in each gallery.

= 1.3.2 =
* Security: updates are only installed when they carry a valid signature from the publisher. A tampered or unsigned update is refused and nothing is installed.

= 1.3.1 =
* Fix: on themes that build the thumbnail row with the same WooCommerce filter (such as Flatsome), the banner also appeared on a thumbnail. It now only appears on the large gallery images.
* Dutch translation: the WooCommerce setting is now called by its exact Dutch name.

= 1.3.0 =
* The banner on the product image is now regular HTML instead of CSS text, so translation plugins such as TranslatePress translate it. It is placed on the image itself, so it stays centred on themes that show the thumbnails inside the gallery.
* Three banner styles: diagonal, straight band and corner label (top left or top right). New installations start with the corner label; existing sites keep the diagonal banner.
* The banner now has a border in the border colour of the notice.
* Choose where the alternatives button links to: product category (default), shop page or a custom address.
* Status of WooCommerce's "Hide out of stock items from the catalog" on the settings page, with a link.
* wpml-config.xml for WPML and Polylang.

= 1.2.1 =
* Ready for wordpress.org: English source texts with a Dutch translation included, English readme, admin page slug changed to `sk-oosn` (old links redirect), "Requires Plugins: woocommerce" header, cleaner uninstall.
* "Settings" link in the plugins list.

= 1.2.0 =
* The notice now also works with themes that place the order block outside the product summary, such as Flatsome with a custom product layout. Previously the options and "Choose an option" stayed visible there and the notice did not appear.
* Sold out options (such as sizes) disappear from the dropdown instead of being greyed out. On by default.
* The product image is no longer greyed out by default. Turn it on with "Grey out product image".
* Configurable colours for the banner and the notice.
* Per product (Inventory tab): turn the notice off, choose between "Temporarily out of stock" and "Not coming back", and set your own text.
* An empty button text means no button is shown.

= 1.1.3 =
* Updates are delivered automatically through the SK update server.
* Maintenance: the shared SK components meet the requirements of the WordPress Plugin Review Team. No functional changes.

= 1.1.0 =
* Settings page moved to the shared SK admin shell. No functional changes to the notice itself.

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.4.0 =
New neutral default look. If you never changed the colours, your shop gets the new look; custom colours are kept.

= 1.3.0 =
The banner is now translatable and gets a border in the notice border colour. Your existing style (diagonal) and texts are kept.

= 1.2.1 =
Admin texts are now English with a Dutch translation included. Saved texts are kept as they are.
