[5.7] Added ContainsPurchasablesConditionRule#4243
Merged
Conversation
…es-condition-rule
- Correct @SInCE from 4.2.0 to 5.7.0 - Remove double space in namespace declaration - Fix @inerhitdoc typo to @inheritdoc - Add CHANGELOG-WIP.md entry for HasPurchasablesConditionRule
For 'all', use one EXISTS subquery per purchasable ID (AND-joined) so the DB-level filter is accurate, not just a broad pre-filter. For 'any', the existing IN condition is correct. For 'exact', keep the IN pre-filter and let matchElement handle the rest.
…sablesConditionRule - Add OrderQuery::$containsPurchasables property and containsPurchasables() method supporting 'any', 'all', and 'only' match modes with correct SQL for each - Rename HasPurchasablesConditionRule to ContainsPurchasablesConditionRule and update its label to 'Contains Purchasables' - modifyQuery now delegates entirely to containsPurchasables() so all three match modes are correctly handled at the DB level
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 a new Contains Purchasables order condition rule with three match modes:
hasPurchasablesvscontainsPurchasablesThe existing
hasPurchasablesquery param is unchanged. It accepts a single purchasable or a flat array of purchasables/IDs and always uses "any" matching — i.e. the order must contain at least one of them.The new
containsPurchasablesparam accepts an array shape with apurchasableskey (mixed IDs and/or objects) and amatchkey (ContainsPurchasablesMatchenum). All three modes are handled with correct SQL:anyEXISTSwithIN (...)allEXISTSper ID, AND-joinedonlyEXISTSper ID +NOT EXISTSfor any othersTwig examples
New classes and methods
Added
craft\commerce\elements\conditions\orders\ContainsPurchasablesConditionRule.Added
craft\commerce\enums\ContainsPurchasablesMatch.Added
craft\commerce\elements\db\OrderQuery::$containsPurchasables.Added
craft\commerce\elements\db\OrderQuery::containsPurchasables().Added
craft\commerce\elements\Order::hasPurchasables().Needs translations
Fixes #4242