To show “% discount” in a facet, we’ll first create the facet:

We’re setting the Data source to Post Type just as a placeholder.

Next, we add an indexer hook to calculates the percent discount and modify the index value. Add the following into your (child) theme’s functions.php:

[calculate_discount]

Make sure to re-index afterwards.

See also

Last updated: September 10, 2024