-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support discounts specifying fields in the discount UI #1653
Support discounts specifying fields in the discount UI #1653
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks @ryanmitchell Going to try and get my head into and take a look at this soon :) @glennjacobs did you have any opinions in the meantime? |
Any more thoughts on this one? Its the only thing holding us back from rolling 1.x out, so it would be great to find a solution. |
@ryanmitchell I think this approach is fine. Here are my thoughts... The new methods don't implement an interface but I think they should. The core provides the And then finally we could do with updating the documentation to cover this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments above for requested changes.
@glennjacobs thanks for reviewing and your feedback. I've pushed up the changes requested. |
Just checking in on this - it would be great to get reviewed again to make the next alpha if possible. |
Currently custom discounts cant specify fields the filament UI.
This PR attempts to fix that by allowing discounts to specify 3 'magic' methods:
lunarPanelSchema(): array
The Filament schema for the fields to be displayed when the discount type is specified
lunarPanelOnFill(array $data): array
To allow the discount to modify the data associated with the discount before its rendered (only called if the discount type is selected)
lunarPanelOnSave(array $data): array
To allow the discount to modify the data associated with the discount before its saved (only called if the discount type is selected)
Here is an example of how it is used, in a Amount off (Retail price) discount that we use in one of our systems:
As you can see we are using some of the same data values as the standard "Amount off" discount, but we have to prefix them in the schema to avoid collisions on the filament side... then on fill/save we add/undo those prefixes so they dont get saved to the database. This is just a simple example to show how they can used and why they are necessary.
The benefit of this approach is that the discount is just registered once, making the DX experience simpler.