Skip to content

fix: open products with a price for editing - #38

Merged
roble merged 1 commit into
mainfrom
renanroble/fix-product-edit-currency
Nov 4, 2026
Merged

roble merged 1 commit into
mainfrom
renanroble/fix-product-edit-currency

Conversation

@roble

@roble roble commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Editing a product with a price crashes:

Currency::from(): Argument #1 ($value) must be of type string|int, Modules\Billing\Enums\Currency given

Price casts currency to the enum, so a saved row's state holds a Currency, while the repeater's item label passed it to Currency::from(). Unsaved rows hold a string.

Fix

Move the label into ProductForm::priceLabel(), which accepts either form, as kindIs() already does for PlanKind.

Tests

  • New test_a_plan_with_a_price_opens_for_editing failed with the reported error before the fix.
  • Billing suite passes (513). Pint clean. Not checked in a browser.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Product price labels now display the formatted amount, currency, and billing interval when the required price details are available.

The price repeater's item label called Currency::from() on the row's
currency, which is already the enum once loaded from a saved Price, so
the edit page crashed for any product with a price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The product price repeater now uses a helper to format item labels. A feature test checks that a product with a monthly USD price displays $9.00 on its edit page.

Changes: Product price labels

Layer / File(s) Summary
Price label formatting and verification
src/Filament/Resources/Products/Schemas/ProductForm.php, tests/Feature/ProductFormLayoutTest.php
priceLabel returns null when the amount or currency is blank. Otherwise, it formats the amount, interval, and interval count, defaulting the count to 1. The prices repeater uses this helper, and a feature test checks the rendered price on the edit page.

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

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 6244a

The saved-price editing crash is addressed, and the added feature test covers the reported workflow.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

PHPStan (2.3.1)

Composer install failed: the lock file is not up to date with the latest changes in composer.json. Run composer update and commit the updated composer.lock.

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

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@roble
roble merged commit 38244fe into main Nov 4, 2026
4 of 5 checks passed
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.

1 participant