Skip to content

fix: print item kit name on receipts for Kit Only print - #4635

Open
richardmilles wants to merge 3 commits into
opensourcepos:masterfrom
richardmilles:fix-4154-kit-name-receipt
Open

fix: print item kit name on receipts for Kit Only print#4635
richardmilles wants to merge 3 commits into
opensourcepos:masterfrom
richardmilles:fix-4154-kit-name-receipt

Conversation

@richardmilles

@richardmilles richardmilles commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Kit price/print options were typed as bool, so PRINT_KIT was coerced and kit-mode print overrides were ignored. This passes ints, honors an explicit print override for the linked kit item, and displays item_kits.name on the receipt line.

Fixes #4154

Summary by CodeRabbit

  • Bug Fixes
    • Improved item-kit printing behavior in sales.
    • Kit-only printing now correctly marks linked items for printing and labels cart lines with the kit name.
    • Explicit print selections now take priority over default kit printing rules.
    • Improved handling of kit pricing and print options when adding items to a sale.

Cast kit price/print options as ints (bool coercion broke PRINT_KIT), honor an explicit print override in kit mode, force the linked kit item printable, and display item_kits.name on the receipt line.

Fixes opensourcepos#4154
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Item-kit sales now pass explicit print options, apply integer kit options, and rename the linked cart line to the kit name for kit-only printing.

Changes

Item Kit Printing

Layer / File(s) Summary
Kit print-option handling
app/Libraries/Sale_lib.php
add_item and add_item_kit now use integer print-option parameters. Explicit print options take precedence over kit print-option rules.
Item-kit sale wiring
app/Controllers/Sales.php
Item-kit sales pass the print option, cast kit options to integers, and update the linked cart line with the kit name and print option.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested reviewers: jekkos, objecttothis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the fix for displaying item kit names on receipts when using Kit Only printing.
Linked Issues check ✅ Passed The changes address issue #4154 by displaying the kit name and honoring Kit Only price and print options.
Out of Scope Changes check ✅ Passed All changes support item kit receipt printing and option handling; no unrelated code changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Controllers/Sales.php`:
- Around line 575-582: Ensure each item kit gets a distinct cart header identity
after Sale_lib::add_item(), rather than locating lines by item_id alone. Update
the kit-header creation and subsequent loop so only the newly added kit line
receives the item-kit name and PRINT_KIT print option, preserving separate
headers when linked items or multiple kits share the same item_id.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3edc4c42-ea60-4afc-a1f6-0fafc0049d67

📥 Commits

Reviewing files that changed from the base of the PR and between aa96ad0 and 887d744.

📒 Files selected for processing (2)
  • app/Controllers/Sales.php
  • app/Libraries/Sale_lib.php

Comment thread app/Controllers/Sales.php
Comment on lines +575 to +582
foreach ($cart as $line => $cart_item) {
if ((string)$cart_item['item_id'] === (string)$kit_item_id) {
$cart[$line]['name'] = $item_kit_info->name;
if ((int)$kit_print_option === PRINT_KIT) {
$cart[$line]['print_option'] = PRINT_YES;
}
}
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Use a unique cart-line identity for the kit header.

Sale_lib::add_item() merges non-serialized lines by item_id and item_location. If the sale already contains $kit_item_id, this loop renames that ordinary line to the item-kit name and, for PRINT_KIT, forces it printable. A later kit with the same linked item can also overwrite the earlier kit name.

Create or retain a distinct header line for each item kit. Update only that line after add_item(). Do not select receipt lines by item_id alone.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Controllers/Sales.php` around lines 575 - 582, Ensure each item kit gets
a distinct cart header identity after Sale_lib::add_item(), rather than locating
lines by item_id alone. Update the kit-header creation and subsequent loop so
only the newly added kit line receives the item-kit name and PRINT_KIT print
option, preserving separate headers when linked items or multiple kits share the
same item_id.

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.

[Bug]: Item Kits name not being displayed/printed on receipt

3 participants