feat: add free quantities for menu item options - #133
Merged
Conversation
Lets an option group value be free for a configurable number of units, consumed in the order the customer selects values, bounded by each value's own budget and an optional shared cap on the whole group.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces “free quantity” support for menu item option groups and option values, allowing the cart to grant a limited number of free units (by selection order), reflect discounted subtotals, and persist the granted free units into order history records.
Changes:
- Add
free_quantityconfiguration to menu item option groups and option values, plus admin form fields and translations. - Allocate and apply
free_qtyduring cart option preparation, and deduct free units inCartItemOptionValue::subtotal(). - Persist
free_qtyintoorder_menu_optionsand adjust order email pricing display accordingly.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Models/MenuItemOptionValueTest.php | Extends model fillable/rules assertions for free_quantity. |
| tests/Models/MenuItemOptionTest.php | Extends model fillable/rules assertions for free_quantity. |
| tests/Classes/CartManagerTest.php | Adds coverage for free-quantity allocation behavior in CartManager. |
| tests/CartItemOptionValueTest.php | Adds unit tests for CartItemOptionValue subtotal behavior with free units. |
| src/Models/OrderMenuOptionValue.php | Adds free_qty cast and docblock for order option persistence. |
| src/Models/Order.php | Adjusts order mail pricing display to subtract free_qty. |
| src/Models/MenuItemOptionValue.php | Adds free_quantity fillable/cast/rule for per-value budgets. |
| src/Models/MenuItemOption.php | Adds free_quantity fillable/cast/rule and exposes per-value free_quantity in option values. |
| src/Models/Concerns/ManagesOrderItems.php | Persists free_qty into order_menu_options. |
| src/Classes/CartManager.php | Adds free-quantity allocation and threads free_qty into prepared option values. |
| src/CartItemOptionValue.php | Adds free_qty and deducts it from subtotal; includes free_qty in serialization. |
| resources/models/menuitemoptionvalue.php | Adds admin form field for per-value free_quantity. |
| resources/models/menuitemoption.php | Adds admin form field for group free_quantity cap. |
| resources/lang/en/default.php | Adds user-facing labels/help text related to free quantities. |
| database/migrations/2026_07_11_010200_add_free_qty_to_order_menu_options_table.php | Adds free_qty column (needs rollback/guard improvements). |
| database/migrations/2026_07_11_010100_add_free_quantity_to_menu_item_option_values_table.php | Adds free_quantity column (needs rollback/guard improvements). |
| database/migrations/2026_07_11_010000_add_free_quantity_to_menu_item_options_table.php | Adds free_quantity column (needs rollback/guard improvements). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
sampoyigi
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
free_quantitycap on a menu item option group (e.g. "Toppings") and a per-valuefree_quantitybudget on each option value.CartManagerallocates free units to selected values in the order they were picked, bounded by each value's own budget and the group's shared cap.CartItemOptionValue::subtotal()deducts granted free units from the chargeable quantity.order_menu_optionsfor accurate order-history display.