Skip to content

Fix fatal in WC notifications when an order item's product is deleted#85

Open
akzmoudud wants to merge 3 commits into
feature/dashboardfrom
fix/wc-notification-deleted-product-fatal
Open

Fix fatal in WC notifications when an order item's product is deleted#85
akzmoudud wants to merge 3 commits into
feature/dashboardfrom
fix/wc-notification-deleted-product-fatal

Conversation

@akzmoudud
Copy link
Copy Markdown

@akzmoudud akzmoudud commented May 15, 2026

closes: https://github.com/getdokan/texty-pro/issues/25

Summary

  • Guard against WC_Order_Item_Product::get_product() returning false in Notifications\WC\Base::get_items(). Previously, calling get_name() on the false return fataled and brought down whatever request triggered the send (admin order screen, status change, REST call).
  • Items pointing at a deleted/trashed product are now skipped; the rest of the {items} token still renders for the surviving products and the notification goes out.

Root cause

get_product() returns false when the linked product has been permanently deleted. The old code dereferenced it directly:

$product    = $item->get_product();
$products[] = sprintf( '%s x %d', $product->get_name(), $item->get_quantity() );

@akzmoudud akzmoudud self-assigned this May 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8471beac-e4bf-4744-ad8f-8db9005532a9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wc-notification-deleted-product-fatal

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

akzmoudud added 2 commits May 15, 2026 16:42
Lets listeners on the existing texty_notification_recipients filter look up
the customer the SMS is destined for without reaching into the order
themselves. Returns 0 for guest orders so callers can short-circuit
identity-required gates (e.g. texty-pro's consent module) without
extra null checks.

Pure data accessor — no behavior change in the send path.
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