Skip to content

Handle soft deleted purchasable on order lines#2302

Merged
alecritson merged 1 commit into1.xfrom
fix-deleted-purchasble-order-line
Sep 30, 2025
Merged

Handle soft deleted purchasable on order lines#2302
alecritson merged 1 commit into1.xfrom
fix-deleted-purchasble-order-line

Conversation

@alecritson
Copy link
Collaborator

@alecritson alecritson commented Sep 30, 2025

Currently when viewing an order in the panel a link is provided to the product, however if this product has been soft deleted then an exception is thrown due to trying to get the product to provide a link.

This is a small PR which will check for the existence of the purchasable relation before attempting to generate the link to ensure the page will still load in the event the product has been deleted.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented errors when viewing order item descriptions without an associated purchasable/product. The app now skips link generation when data is missing, avoiding crashes and broken links in the Order Items table. This improves stability, ensures pages load reliably, and delivers a smoother admin experience with consistent behavior even for incomplete or legacy order data.

@vercel
Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lunar-docs Ready Ready Preview Comment Sep 30, 2025 9:04am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Adds a null-check when generating the description URL in OrderItemsTable to ensure purchasable exists before accessing its product_id, avoiding null dereference and skipping URL resolution when absent.

Changes

Cohort / File(s) Summary
Order items table URL guard
packages/admin/src/Filament/Resources/OrderResource/Pages/Components/OrderItemsTable.php
Add conditional check to verify $line->purchasable is non-null before accessing product_id during description URL generation; skips URL creation if missing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • glennjacobs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core change of handling scenarios where a soft-deleted purchasable is encountered on order lines, aligning closely with the pull request’s intent and avoiding unnecessary detail.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-deleted-purchasble-order-line

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2e6a30 and 3fecf77.

📒 Files selected for processing (1)
  • packages/admin/src/Filament/Resources/OrderResource/Pages/Components/OrderItemsTable.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/admin/src/Filament/Resources/OrderResource/Pages/Components/OrderItemsTable.php (2)
packages/core/src/Models/ProductVariant.php (1)
  • ProductVariant (55-226)
packages/core/src/Base/Traits/HasModelExtending.php (1)
  • morphName (97-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: shipping - PHP 8.4 - L12.* ↑
  • GitHub Check: stripe - PHP 8.4 - L12.* ↑
  • GitHub Check: core - PHP 8.4 - L12.* ↑ E
  • GitHub Check: core - PHP 8.4 - L12.* ↑
  • GitHub Check: admin - PHP 8.4 - L12.* ↑
  • GitHub Check: admin - PHP 8.4 - L12.* ↑ E
  • GitHub Check: search - PHP 8.4 - L11.* ↑ E
  • GitHub Check: admin - PHP 8.4 - L11.* ↑
  • GitHub Check: core - PHP 8.4 - L11.* ↑
  • GitHub Check: admin - PHP 8.4 - L11.* ↑ E
  • GitHub Check: core - PHP 8.4 - L11.* ↑ E
  • GitHub Check: core - PHP 8.3 - L12.* ↑ E
  • GitHub Check: core - PHP 8.3 - L12.* ↑
  • GitHub Check: admin - PHP 8.3 - L12.* ↑
  • GitHub Check: admin - PHP 8.3 - L12.* ↑ E
  • GitHub Check: core - PHP 8.3 - L11.* ↑
  • GitHub Check: admin - PHP 8.3 - L11.* ↑
  • GitHub Check: admin - PHP 8.3 - L11.* ↑ E
  • GitHub Check: core - PHP 8.3 - L11.* ↑ E
🔇 Additional comments (1)
packages/admin/src/Filament/Resources/OrderResource/Pages/Components/OrderItemsTable.php (1)

48-55: LGTM! Null check prevents exception on soft-deleted purchasables.

The added null check correctly prevents attempting to access product_id when the purchasable has been soft deleted or is otherwise missing, allowing the order page to load gracefully.


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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

Copy link
Contributor

Copilot AI left a comment

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 fixes an issue where viewing orders in the admin panel would throw exceptions when order lines reference soft-deleted products. The fix adds a null check for the purchasable relation before attempting to generate product links.

  • Adds null safety check for purchasable relation before accessing its properties
  • Prevents exceptions when generating product links for soft-deleted purchasables
  • Ensures order pages remain accessible even with deleted product references

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@alecritson alecritson merged commit c6e1676 into 1.x Sep 30, 2025
81 of 89 checks passed
@alecritson alecritson deleted the fix-deleted-purchasble-order-line branch September 30, 2025 09:36
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