Features

Real sale prices or display only

Published

Every discount rule has a setting, How the discount is applied. It decides whether the rule writes a sale price into each product, or only changes the price shoppers are shown. The difference matters for sorting by price and for price filters.

Available since 0.4.0. Display-only rules are available since 0.1.0.

The two choices

Change each product’s sale price (recommended)Display only: change no product
What happensThe rule writes the discounted price into each product’s Sale price field, records what it changed, and puts every product back when the sale ends.Nothing is written to any product. When WooCommerce reads a product’s price, the add-on answers with the discounted price.
Shop, product page, basket, checkout, ordersDiscounted priceDiscounted price
Sorting by priceUses the sale priceUses the old price
WooCommerce’s price filter, and filter plugins such as Super Speedy FiltersUse the sale priceUse the old price
Feeds, search indexes and other plugins that read stored pricesSee the sale priceSee the old price
Cost of saving the ruleA bulk write, then WooCommerce’s save hooks run in batchesOne settings save, whatever the number of products

Why sorting and filters need real sale prices

WooCommerce sorts by price and filters by price from the prices stored in the database, not from the price shown on the page. A display-only rule changes the price shown and leaves the stored price alone, so a shopper filtering up to 50 does not find a 60 product discounted to 45, and a sort by price places it as if it still cost 60.

A rule that changes sale prices writes the sale price where WooCommerce looks for it: each product’s sale price and active price, WooCommerce’s product price lookup table, and the price range of each variable product. Sorting, the price filter and filter plugins all see the sale.

A WooCommerce Jackets category page filtered by price from 2,800 to 4,500 euros. It shows APEX Fleece Jacket at 2,807.20 euros, was 3,190.00, and WILDER Down jacket with fur collar at 4,303.20 euros, was 4,890.00, both with a Sale badge.
A price filter of 2,800 to 4,500 finds the 3,190.00 jacket at its sale price of 2,807.20.
Best for
  • Change each product’s sale price: any sale where shoppers sort or filter by price, and any store with product feeds or a search index
  • Display only: a short flash sale where sorting and filtering by price do not matter, on a very large catalogue

What saving a rule does

When you save a rule that changes sale prices, every product’s sale price is written there and then, in bulk, so the sale is on the shop, in sorting and in filters the moment the save finishes.

WooCommerce’s save hooks then run for every changed product, so feeds, search indexes, caches and filter plugins catch up. Running the sale price updates covers how those run and where to see their progress.

The rule writes its prices again, or puts products back, by itself:

  • when its From time arrives, and when its To time passes;
  • when you switch it off, delete it, or change it;
  • when a product is added to the rule’s category, or edited, during the sale;
  • when Super Speedy Ajax goes to TEST mode, or Price Discounts is switched off.

Which rule set a price

Wherever you see a product, you can tell when a rule set its sale price.

  • Products list. A purple tag with the discount sits beside the price. A variable product gets the tag when a rule set any of its variations’ prices.
  • Sale prices tab. The Discount rule column reads “Sale price set by rule …, undone when it ends”.
  • Product edit screen. A note under the Sale price field names the rule and says what the product goes back to when the rule ends.
The WooCommerce Products list. APEX Fleece Jacket, PHANTOM 3-in-1 Transformer Jacket and WILDER Down jacket each show their regular price struck through, the sale price, and a purple -12% tag from the discount rule. Bags and a pair of shoes without the rule have no tag.
The purple tag marks every product whose sale price a rule set.
The WooCommerce product data panel for a jacket: Regular price 4890, Sale price 4303.20, and a purple note reading: This sale price was set by the rule Black Friday jackets. When the rule ends the product goes back to no sale price. Change it here and the rule leaves this product alone.
The note says which rule set the price and what the product goes back to.

Change the sale price on this screen and the rule leaves the product alone from then on. When a sale ends explains what happens to it.

Display-only rules on the product edit screen

While a display-only rule sets a product’s price, its Sale price field is drawn as virtual: a dashed purple border, the rule’s price as placeholder text and a tag with the discount inside the field. A box directly underneath names the rule (linked to the Discounts tab), the price shoppers pay and, for a rule with a To date, when it ends. Each variation of a variable product gets the same.

The WooCommerce product data panel. Regular price 4890; the Sale price field is dashed purple with 4303.20 as its placeholder and a -12% tag inside it; a box underneath reads -12% applied by Price Discounts, virtual, Rule Black Friday jackets: shoppers pay 4,303.20. Nothing is saved to this product.
The field is empty: the product has no sale price of its own, and saving it stores nothing from the rule.

The field itself stays empty, because the product has no sale price of its own, and saving the product does not store the discounted price.

Typing a sale price into the field gives the product its own sale price. The field returns to normal and the box turns amber and says what the rule then does, following its “If a product has its own sale price” setting.

TEST mode

Discount rules follow Super Speedy Ajax’s TEST and LIVE switch. In TEST mode:

  • a rule discounts nothing for ordinary visitors, and only the secret test link sees it;
  • a rule that changes sale prices writes nothing to any product;
  • switching from LIVE back to TEST puts every product back.

Going LIVE writes the sale prices straight away while the Discounts tab is open.

Did you know?

Switching between the two choices on a rule is safe at any time. Change a rule to display only and save, and every product it wrote is put back as its When the sale ends setting says, while shoppers keep seeing the discount.

Further reading

what each product gets back, and prices edited by hand
the save hooks, progress and the background option
every other setting on a rule

Written for Super Speedy Ajax – Price Discounts 0.4.3.

Comments