Skip to content

Commit

Permalink
Fixes at promotion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Aug 23, 2024
1 parent dd43388 commit 00bddb4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Promotion/Actions/CartFixedDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function apply(object $subject, array $configuration): array
if ($subject instanceof Adjustable) {
$result[] = $subject->adjustments()->create($this->getAdjuster($configuration));
}
//@todo also set the origin

return $result;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Promotion/Models/Coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public function canBeUsed(): bool

public function isExpired(): bool
{
if (null === $this->expires_at) {
return false;
}

return $this->expires_at->isPast();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Promotion/Models/Promotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getActions(): Collection

public function isValid(?\DateTimeInterface $at = null): bool
{
if ($this->usage_count >= $this->usage_limit) {
if (null !== $this->usage_limit && $this->usage_count >= $this->usage_limit) {
return false;
}

Expand Down

0 comments on commit 00bddb4

Please sign in to comment.