-
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.
Merge branch 'develop' into bugfix/3298-4x-sale-discount-set-dateupda…
…ted-+-datecreated-after-save
- Loading branch information
Showing
8 changed files
with
77 additions
and
46 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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -15,13 +15,17 @@ | |
use craft\elements\conditions\ElementConditionRuleInterface; | ||
use craft\elements\db\ElementQueryInterface; | ||
use craft\elements\User; | ||
use craft\helpers\Cp; | ||
use craft\helpers\Db; | ||
use yii\base\InvalidConfigException; | ||
use yii\db\Expression; | ||
|
||
/** | ||
* Customer Condition Rule | ||
* | ||
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 4.2.0 | ||
* @TODO change the class that the `CustomerConditionRule` extends | ||
*/ | ||
class CustomerConditionRule extends BaseMultiSelectConditionRule implements ElementConditionRuleInterface | ||
{ | ||
|
@@ -35,6 +39,7 @@ public function getLabel(): string | |
|
||
/** | ||
* @return array | ||
* @deprecated in 4.3.1. | ||
*/ | ||
protected function options(): array | ||
{ | ||
|
@@ -47,6 +52,24 @@ protected function options(): array | |
->all(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function inputHtml(): string | ||
{ | ||
$users = User::find()->status(null)->limit(null)->id($this->values)->all(); | ||
|
||
return Cp::elementSelectHtml([ | ||
'name' => 'values', | ||
'elements' => $users, | ||
'elementType' => User::class, | ||
'sources' => null, | ||
'criteria' => null, | ||
'condition' => null, | ||
'single' => false, | ||
]); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -63,10 +86,11 @@ public function modifyQuery(ElementQueryInterface $query): void | |
/** @var OrderQuery $query */ | ||
$paramValue = $this->paramValue(); | ||
if ($this->operator === self::OPERATOR_NOT_IN) { | ||
$paramValue = ['or', $paramValue, null]; | ||
// Account for the fact the querying using a combination of `not` and `in` doesn't match `null` in the column | ||
$query->andWhere(Db::parseParam(new Expression('coalesce([[commerce_orders.customerId]], -1)'), $paramValue)); | ||
} else { | ||
$query->customerId($paramValue); | ||
} | ||
|
||
$query->customerId($paramValue); | ||
} | ||
|
||
/** | ||
|