Promotional pricing query methods #3670
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds
PurchasableQuery::hasPromotionalPrice()
to aid in discovering purchasables with a promotional price less than their regular price. This is designed as a replacement for thehasSales()
query parameter for legacy Commerce applications.Our Listing Products On Sale Knowledge Base article covers some DIY versions of this method—and a few advanced arithmetic queries! (I'll update this after this PR is merged.)
We've talked internally about what being “on promotion” actually means—currently, the comparisons are done against catalog pricing—but there are definitely developers and store managers who would expect that the system looks at the base prices (i.e. base price > price, or base price > promotional price), not just the fully-resolved catalog prices!
The existence of a base promotional price is a bit more challenging to detect (as far as query complexity goes), but I am pretty confident that the result would be the same… whether you check for an empty
basePromotionalPrice
orprice = promotionalPrice
would net the same results, due to the way purchasable prices are translated into the catalog pricing table (and then normalized/aggregated during the query).