Skip to content

Commit

Permalink
Merge pull request #28 from grininc/bugfix/magento-2.4.7-compatibility
Browse files Browse the repository at this point in the history
Update SalesRuleValidator and ValidateByToken for Coupon Code Validation
  • Loading branch information
jvillalta-grin authored Sep 9, 2024
2 parents 3f79a71 + 6dc4987 commit 497329d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Model/SalesRuleValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ public function __construct(Request $request, SystemConfig $systemConfig)
}

/**
* @param Rule $rule
* @param string $couponCode
* @param Rule $rule
* @param array $couponCode
* @return bool
*/
public function isValid(Rule $rule, string $couponCode): bool
public function isValid(Rule $rule, array $couponCode): bool
{
if ($rule->getData('is_grin_only') && ($rule->getPrimaryCoupon()->getCode() === $couponCode)) {
$code = $rule->getPrimaryCoupon()->getCode();

if ($code !== null && $rule->getData('is_grin_only') && in_array($code, $couponCode)) {
return $this->request->getHeader(self::TOKEN_HEADER) === $this->systemConfig->getSalesRuleToken();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function aroundApplyRules(
$couponCode
): array {
foreach ($rules as $rule) {
if (!$this->salesRuleValidator->isValid($rule, (string) $couponCode)) {
if (!$this->salesRuleValidator->isValid($rule, $couponCode)) {
return $proceed($item, [], $skipValidation, $couponCode);
}
}
Expand Down

0 comments on commit 497329d

Please sign in to comment.