Allow a purchasable to define it's option attributes #2429
Replies: 2 comments
-
What are the chances this leads to In the interim, an explicit event for attaching extra Event::on(
LineItem::class,
LineItem::EVENT_DEFINE_RULES,
function (DefineRulesEvent $event) {
$event->rules[] = [
'options',
function ($attribute, $params, $validator) use ($event) {
// Check presence of certain attributes, etc!
},
'skipOnEmpty' => false,
'when' => function ($li) {
// Lazily determine whether the validator relevant:
return $this->serviceName->computeSomeCriteria($li);
}
];
}); In thinking about this, though, I'm realizing I might misunderstand—is this just a way for built-in and third-party Purchasables to automatically register these, or a dynamic rule builder UI? Maybe it's ultimately the same feature? (i.e. whatever UI is just a means for building extra |
Beta Was this translation helpful? Give feedback.
-
Please don't transfer lineItems to elements. While it would have some benefits like eager loading (that's luckily solved by now) elements are much more resource heavy and consume an unnecessary amount of DB performance. |
Beta Was this translation helpful? Give feedback.
-
Purchasables should be able to define the following:
For example the donation purchasable should be able to define the follow:
This would allow us to generate an add to cart UI specifically for that purchasable.
Beta Was this translation helpful? Give feedback.
All reactions