verbb / events

Craft CMS Plugin for events management and ticketing.
Other
22 stars 13 forks source link

Function availableQuantity of Ticket class returns bool #135

Closed mihob closed 9 months ago

mihob commented 10 months ago

Describe the bug

The availableQuantity function of the Ticket class always returns a bool.

Shouldn't the return type be mixed?

    public function availableQuantity(): bool
    {
        // Check if the event overall even has anymore to buy - that's a hard-unavailable
        if ($this->event->getAvailableCapacity() < 1) {
            return false;
        }

        // If we've specifically not set a quantity on the ticket, treat it like unlimited
        return $this->quantity ?? $this->event->getAvailableCapacity();
    }

Steps to reproduce

  1. Use the availableQuantity function of a ticket to output the number of available tickets in the template, for example

Craft CMS version

Craft Pro 4.6.0

Plugin version

2.0.3

Multi-site?

Yes

Additional context

No response

engram-design commented 10 months ago

Updated for the next release. To get this early, run composer require verbb/events:"dev-craft-4 as 2.0.3".

engram-design commented 9 months ago

Updated in 2.0.4