Skip to content

Error when adding shipping/billing address to order without existing address #2392

@jamiesage123

Description

@jamiesage123
  • Lunar version: 1.2.1
  • Laravel Version: 11.47.0
  • PHP Version: 8.4.15
  • Database Driver & Version: MySQL 8.0

Expected Behaviour:

When an order doesn't have an existing shipping or billing address, clicking the "Edit" button should open a modal with an empty form, allowing the staff user to add a new address to the order. Upon saving, a new address record should be created and associated with the order. The timeline should include the new address details in the activity log, just as it does when updating an existing address.

Actual Behaviour:

When attempting to edit a shipping or billing address on an order that doesn't have one yet, the system throws an error trying to call methods on a null relationship, preventing the address from being added.

Steps To Reproduce:

  1. Create an order without setting a shipping or billing address
  2. Navigate to the order in the admin panel as a staff user
  3. Click the "Edit" button on the shipping or billing address section
  4. Fatal 500 error: Call to a member function toArray() on null vendor/lunarphp/lunar/src/Filament/Resources/OrderResource/Concerns/DisplaysOrderAddresses.php:210

This appears to be occurring due to the fillForm not handling null addresses for both shipping and billing. Additionally, the action does not handle creating new addresses and assumes that its always editing an existing one

NB: In my use case, I have a custom cart validation for some scenarios where a billing and/or shipping addresses aren't required on an order. The default Lunar cart validation does prevent you from adding an order without a valid billing address, and does require a shipping address when the product is shippable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions