Skip to content

Commit

Permalink
Use UID
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Nov 6, 2024
1 parent 01d6a44 commit c95eb01
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use craft\commerce\elements\Order;
use craft\commerce\Plugin;
use craft\elements\conditions\ElementConditionRuleInterface;
use craft\helpers\ArrayHelper;
use yii\db\QueryInterface;

/**
Expand Down Expand Up @@ -41,7 +42,7 @@ public function getExclusiveQueryParams(): array
protected function options(): array
{
return Plugin::getInstance()->getGateways()->getAllGateways()->mapWithKeys(function($gateway) {
return [$gateway->id => $gateway->name];
return [$gateway->uid => $gateway->name];
})->all();
}

Expand All @@ -50,8 +51,9 @@ protected function options(): array
*/
public function modifyQuery(QueryInterface $query): void
{
$gateway = Plugin::getInstance()->getGateways()->getAllGateways()->firstWhere('uid', $this->value);
/** @var OrderQuery $query */
$query->gatewayId($this->value);
$query->gatewayId($gateway->id);
}

/**
Expand All @@ -60,6 +62,7 @@ public function modifyQuery(QueryInterface $query): void
public function matchElement(ElementInterface $element): bool
{
/** @var Order $element */
return $this->matchValue($element->gatewayId);
$gatewayUid = $element->getGateway()?->uid;
return $this->matchValue($gatewayUid);
}
}

0 comments on commit c95eb01

Please sign in to comment.