|
38 | 38 | use yii\web\HttpException; |
39 | 39 | use yii\web\Response; |
40 | 40 | use function explode; |
41 | | -use function get_class; |
42 | 41 |
|
43 | 42 | /** |
44 | 43 | * Class Discounts Controller |
@@ -459,17 +458,11 @@ public function actionClearDiscountUses(): Response |
459 | 458 | return $this->asFailure(Craft::t('commerce', 'Type not in allowed options.')); |
460 | 459 | } |
461 | 460 |
|
462 | | - switch ($type) { |
463 | | - case self::DISCOUNT_COUNTER_TYPE_EMAIL: |
464 | | - Plugin::getInstance()->getDiscounts()->clearEmailUsageHistoryById($id); |
465 | | - break; |
466 | | - case self::DISCOUNT_COUNTER_TYPE_CUSTOMER: |
467 | | - Plugin::getInstance()->getDiscounts()->clearCustomerUsageHistoryById($id); |
468 | | - break; |
469 | | - case self::DISCOUNT_COUNTER_TYPE_TOTAL: |
470 | | - Plugin::getInstance()->getDiscounts()->clearDiscountUsesById($id); |
471 | | - break; |
472 | | - } |
| 461 | + match ($type) { |
| 462 | + self::DISCOUNT_COUNTER_TYPE_EMAIL => Plugin::getInstance()->getDiscounts()->clearEmailUsageHistoryById($id), |
| 463 | + self::DISCOUNT_COUNTER_TYPE_CUSTOMER => Plugin::getInstance()->getDiscounts()->clearCustomerUsageHistoryById($id), |
| 464 | + self::DISCOUNT_COUNTER_TYPE_TOTAL => Plugin::getInstance()->getDiscounts()->clearDiscountUsesById($id), |
| 465 | + }; |
473 | 466 |
|
474 | 467 | return $this->asSuccess(); |
475 | 468 | } |
@@ -678,8 +671,8 @@ private function _populateVariables(array &$variables): void |
678 | 671 | foreach ($purchasableIds as $purchasableId) { |
679 | 672 | $purchasable = Craft::$app->getElements()->getElementById((int)$purchasableId); |
680 | 673 | if ($purchasable instanceof PurchasableInterface) { |
681 | | - $class = get_class($purchasable); |
682 | | - $purchasables[$class] = $purchasables[$class] ?? []; |
| 674 | + $class = $purchasable::class; |
| 675 | + $purchasables[$class] ??= []; |
683 | 676 | $purchasables[$class][] = $purchasable; |
684 | 677 | } |
685 | 678 | } |
|
0 commit comments