Features

Sale pages and on-sale listings

Published

A product a discount rule discounts is on sale everywhere WooCommerce lists on-sale products, so a Sale page shows it next to products that have their own sale price. This works for both kinds of rule, including display-only rules that write nothing to the product.

Available since 0.3.0.

Where rule discounts appear

  • the On Sale Products block, and the Product Collection block set to show products on sale;
  • WooCommerce’s sale products shortcode;
  • the on_sale filter of the Store API and the REST API, which headless shops and many plugins use;
  • the Products widget set to “On-sale products”.

Every one of these asks WooCommerce for its list of on-sale product IDs. The add-on adds the products the rules discount to that list as it is read. Nothing is written to WooCommerce’s own on-sale data.

Which products are listed

A product is listed while a rule in force lowers its price:

  • a rule that cannot lower a product’s price leaves it off, for example a fixed-price rule above the product’s regular price;
  • a variable product is listed when the rule lowers any of its variations;
  • the first rule that matches a product decides, exactly as for prices (see Discount rules);
  • while Super Speedy Ajax is in TEST mode, rule products are added only for the test link.

The list follows the rules as they change: when you save rules, when a scheduled rule starts or ends, and when a product is saved into or out of a rule’s category. The result is cached until one of those happens.

Building a Sale page

  1. Create a page, for example “Sale”.
  2. Add the On Sale Products block, or a Product Collection block with “On sale” ticked.
  3. Publish it.

The page lists products with their own sale price and products a rule discounts, together.

Cached Sale pages

Which products a page lists is part of the cached page, whatever Super Speedy Ajax’s Prices setting. A cached Sale page keeps the list it was built with until the page cache is purged.

Purge the page cache when a sale starts or ends (on by default) does that for you. See Page cache purging.

Theme Sale pages

Some themes build their own Sale page with a database query of their own, instead of one of the listings above. That query reads WooCommerce’s stored sale prices directly:

  • products a rule that changes each product’s sale price has written appear on it, because the sale price is stored in the product;
  • products a display-only rule discounts do not, because nothing is stored.

If your theme’s Sale page is missing products, use rules that change sale prices, or build the Sale page with the On Sale Products block.

Further reading

keep cached Sale pages up to date
which kind of rule stores the sale price
a product is missing from the Sale page

Written for Super Speedy Ajax – Price Discounts 0.4.3.

Comments