Skip to content

feat: add free quantities for menu item options - #133

Merged
sampoyigi merged 5 commits into
4.xfrom
feat/free-quantity-options
Jul 20, 2026
Merged

feat: add free quantities for menu item options#133
sampoyigi merged 5 commits into
4.xfrom
feat/free-quantity-options

Conversation

@obinnaelviso

@obinnaelviso obinnaelviso commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds an optional free_quantity cap on a menu item option group (e.g. "Toppings") and a per-value free_quantity budget on each option value.
  • CartManager allocates 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.
  • Free units are persisted to order_menu_options for accurate order-history display.

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.
Copilot AI review requested due to automatic review settings July 11, 2026 23:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_quantity configuration to menu item option groups and option values, plus admin form fields and translations.
  • Allocate and apply free_qty during cart option preparation, and deduct free units in CartItemOptionValue::subtotal().
  • Persist free_qty into order_menu_options and 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.

Comment thread src/Classes/CartManager.php
Comment thread src/CartItemOptionValue.php Outdated
Comment thread src/CartItemOptionValue.php Outdated
Comment thread src/Models/MenuItemOption.php
Comment thread src/Models/MenuItemOptionValue.php Outdated
Comment thread src/Classes/CartManager.php
obinnaelviso and others added 4 commits July 12, 2026 01:02
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>
@obinnaelviso

Copy link
Copy Markdown
Contributor Author

@sampoyigi
sampoyigi merged commit ab51945 into 4.x Jul 20, 2026
1 of 4 checks passed
@sampoyigi
sampoyigi deleted the feat/free-quantity-options branch July 20, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants