Closed anchovy closed 1 year ago
Or - maybe another option is to only verify the availableTo against the availableFrom and de-couple them from the event endDate. This way users/admins have flexibility to set ticket dates that work for their use case.
Yii rules are a little difficult to "unset", but it certainly is possible! You'll want to loop through any of the rules configured for the element and remove it, adding your own.
use craft\events\DefineRulesEvent;
use verbb\events\elements\Ticket;
use yii\base\Event;
Event::on(Ticket::class, Ticket::EVENT_DEFINE_RULES, function(DefineRulesEvent $event) {
foreach ($event->rules as $key => $rule) {
[$attribute, $validator] = $rule;
if ($attribute === ['availableFrom', 'availableTo']) {
unset($event->rules[$key]);
}
if ($attribute === ['availableFrom']) {
unset($event->rules[$key]);
}
}
});
But you'll need to get on the latest craft-4
branch for that as well.
And yeah, I'll consider that. I was just thinking that there's no point in offering tickets for sale once the end date of the event is over, but this is purely a validation step.
Hi, thanks for that. We've started the upgrade to craft-v4, so I'll get that finished and hook into unsetting these rules. Thanks.
Question
Is it possible to overwrite the ticket element rules?
vendor/verbb/events/src/elements/Ticket.php
We have a slightly different use case where one particular ticket type is used to track attendance to events, so they are only 'purchasable' after the event has finished - so in our case we'd want something like....
So - is it possible to overwrite these rules?
Regards Ben
Additional context
No response