-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added product condition rule for variant conditions
- Loading branch information
1 parent
71b377a
commit 225c924
Showing
3 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# Release Notes for Craft Commerce (WIP) | ||
|
||
## Administration | ||
### Store Management | ||
|
||
- Added support for `to`, `bcc`, and `cc` email fields to support environment variables. ([#3738](https://github.com/craftcms/commerce/issues/3738)) | ||
- Added an `originalCart` value to the `commerce/update-cart` failed ajax response. ([#430](https://github.com/craftcms/commerce/issues/430)) | ||
- Added a new "Payment Gateway" order condition rule. ([#3722](https://github.com/craftcms/commerce/discussions/3722)) | ||
- Order conditions can now have a “Payment Gateway” rule. ([#3722](https://github.com/craftcms/commerce/discussions/3722)) | ||
- Variant conditions can now have a “Product” rule. | ||
|
||
### Extensibility | ||
|
||
- Added `craft\commerce\elements\conditions\variants\ProductConditionRule`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* @link https://craftcms.com/ | ||
* @copyright Copyright (c) Pixel & Tonic, Inc. | ||
* @license https://craftcms.github.io/license/ | ||
*/ | ||
|
||
namespace craft\commerce\elements\conditions\variants; | ||
|
||
use Craft; | ||
use craft\base\conditions\BaseElementSelectConditionRule; | ||
use craft\base\ElementInterface; | ||
use craft\commerce\elements\db\VariantQuery; | ||
use craft\commerce\elements\Product; | ||
use craft\commerce\elements\Variant; | ||
use craft\elements\conditions\ElementConditionRuleInterface; | ||
use craft\elements\db\ElementQueryInterface; | ||
|
||
/** | ||
* Products Condition Rule | ||
* | ||
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class ProductConditionRule extends BaseElementSelectConditionRule implements ElementConditionRuleInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function elementType(): string | ||
{ | ||
return Product::class; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return Craft::t('commerce', 'Product'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getExclusiveQueryParams(): array | ||
{ | ||
return ['product', 'productId', 'primaryOwnerId', 'primaryOwner', 'owner', 'ownerId']; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function modifyQuery(ElementQueryInterface $query): void | ||
{ | ||
/** @var VariantQuery $query */ | ||
$query->ownerId($this->getElementId()); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function matchElement(ElementInterface $element): bool | ||
{ | ||
/** @var Variant $element */ | ||
return $element->getOwnerId() == $this->getElementId(); | ||
} | ||
} |
This file contains 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