Skip to content

Conversation

@shohag121
Copy link
Member

@shohag121 shohag121 commented Oct 20, 2025

…funded

Screenshot 2025-10-20 at 6 55 52 pm

fix: #50

Summary by CodeRabbit

New Features

  • Added notification support for three new order statuses: cancelled, failed, and refunded
  • Administrators now receive notifications when orders are cancelled, fail, or are refunded
  • Customers receive notifications for order cancellations and refunds
  • Vendors receive notifications for status changes across marketplace integrations

@coderabbitai
Copy link

coderabbitai bot commented Oct 20, 2025

Walkthrough

This PR adds SMS notification support for three additional order statuses (cancelled, failed, refunded) across WooCommerce and Dokan integrations, including nine new notification classes for admin, customer, and vendor recipients, plus integration and registry updates to trigger these notifications.

Changes

Cohort / File(s) Summary
Integration Handlers
includes/Integrations/WooCommerce.php, includes/Integrations/Dokan.php
Added three new cases to order_status_changed switch: cancelled, failed, and refunded. WooCommerce sends separate notifications to admin and customer; Dokan sends to vendor. Each case mirrors existing status handling patterns.
Notification Registry
includes/Notifications.php
Expanded notification mappings with six new WooCommerce keys (order_admin_cancelled, order_admin_failed, order_admin_refunded, order_customer_cancelled, order_customer_failed, order_customer_refunded) and three new Dokan keys (order_dokan_cancelled, order_dokan_failed, order_dokan_refunded), each mapped to corresponding notification classes.
WooCommerce Admin Notifications
includes/Notifications/WC/CancelledAdmin.php, includes/Notifications/WC/FailedAdmin.php, includes/Notifications/WC/RefundedAdmin.php
Three new notification classes extending Base, each with constructor initializing title (localized), id, group ("wc"), default_recipients (["administrator"]), and default message template with order and customer placeholders.
WooCommerce Customer Notifications
includes/Notifications/WC/CancelledCustomer.php, includes/Notifications/WC/FailedCustomer.php, includes/Notifications/WC/RefundedCustomer.php
Three new notification classes extending Base, each with constructor initializing title (localized), id, group ("wc"), type ("user"), and default message template addressing the customer with order and site details.
Dokan Vendor Notifications
includes/Notifications/Dokan/CancelledVendor.php, includes/Notifications/Dokan/FailedVendor.php, includes/Notifications/Dokan/RefundedVendor.php
Three new notification classes extending Base, each with constructor initializing title (localized), id, group ("dokan"), type ("vendor"), and default message template with order, customer, and site information.

Sequence Diagram

sequenceDiagram
    participant Order as Order Status<br/>Change
    participant Integration as Integration<br/>(WC/Dokan)
    participant Registry as Notifications<br/>Registry
    participant Notifier as Notification<br/>Class
    participant Recipient as Recipients

    Order->>Integration: order_status_changed(cancelled|failed|refunded)
    activate Integration
    Integration->>Registry: Trigger event (e.g., order_admin_cancelled)
    deactivate Integration
    
    activate Registry
    Registry->>Notifier: Instantiate Notification Class
    Registry->>Recipient: Send to default_recipients
    deactivate Registry
    
    Note over Notifier,Recipient: Message sent with<br/>populated variables
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes comprise 12 new files (9 notification classes) and 3 modified integration/registry files. While the new notification classes follow a consistent, repetitive pattern—each defining metadata and a message template in a constructor—reviewers must verify that each class correctly implements its role (admin vs. customer vs. vendor), validate integration trigger logic for the three new statuses, and confirm registry mappings are properly configured. The homogeneity of the notification classes reduces cognitive load, but the spread across multiple files and the need to cross-reference integration logic and messaging content moderately increases review scope.

Poem

🐰 Three statuses emerge from the cancelled, failed, and refunded stream,
Admin, customer, and vendor—each now share the dream,
SMS notifications hop along the order's way,
With messages and placeholders brightening the day! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR introduces three Dokan vendor notification classes (CancelledVendor, FailedVendor, and RefundedVendor) alongside the six WooCommerce notifications. While these Dokan additions follow the same pattern and are related to the core feature, the linked issue #50 specifically targets "SMS notification events for WooCommerce order statuses" and does not mention Dokan integration requirements. The modifications to Dokan.php and the addition of Dokan notification classes represent a feature expansion beyond the stated scope of issue #50. Clarify whether the Dokan notification support should be part of this PR or split into a separate feature request. If Dokan support is intentional, either update the linked issue description to include Dokan requirements or create a separate issue to track the Dokan enhancement separately. If unintended, remove the Dokan notification classes and related integration changes from this PR.
Linked Issues Check ❓ Inconclusive The PR implements all six required WooCommerce notification classes specified in issue #50: CancelledAdmin, CancelledCustomer, FailedAdmin, FailedCustomer, RefundedAdmin, and RefundedCustomer. The admin notification summaries show titles, message templates, and default recipients (Administrator) that match the specifications exactly. The integration files (WooCommerce.php and Notifications.php) are modified to register and trigger these events appropriately. However, the summaries for customer-side notifications lack sufficient detail to confirm that all default message content and recipient configurations precisely match the linked issue requirements, particularly for CancelledCustomer, FailedCustomer, and RefundedCustomer.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: Add notifications for order statuses: cancelled, failed, and re…" is directly related to the main objective of the changeset. The title clearly identifies the primary change: introducing notifications for three additional order statuses (cancelled, failed, and refunded). The title is concise, specific, and accurately represents the core purpose of the modifications across multiple integration and notification files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/new-notification

📜 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 f1827ce and 6fcc6b7.

📒 Files selected for processing (12)
  • includes/Integrations/Dokan.php (1 hunks)
  • includes/Integrations/WooCommerce.php (1 hunks)
  • includes/Notifications.php (1 hunks)
  • includes/Notifications/Dokan/CancelledVendor.php (1 hunks)
  • includes/Notifications/Dokan/FailedVendor.php (1 hunks)
  • includes/Notifications/Dokan/RefundedVendor.php (1 hunks)
  • includes/Notifications/WC/CancelledAdmin.php (1 hunks)
  • includes/Notifications/WC/CancelledCustomer.php (1 hunks)
  • includes/Notifications/WC/FailedAdmin.php (1 hunks)
  • includes/Notifications/WC/FailedCustomer.php (1 hunks)
  • includes/Notifications/WC/RefundedAdmin.php (1 hunks)
  • includes/Notifications/WC/RefundedCustomer.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (12)
includes/Notifications/WC/CancelledCustomer.php (3)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/WC/CancelledAdmin.php (1)
  • __construct (10-22)
includes/Notifications/WC/FailedCustomer.php (1)
  • __construct (10-19)
includes/Notifications/WC/RefundedAdmin.php (5)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/Dokan/RefundedVendor.php (1)
  • __construct (10-22)
includes/Notifications/WC/CancelledAdmin.php (1)
  • __construct (10-22)
includes/Notifications/WC/FailedAdmin.php (1)
  • __construct (10-22)
includes/Notifications/WC/RefundedCustomer.php (1)
  • __construct (10-19)
includes/Integrations/Dokan.php (2)
includes/Integrations/WooCommerce.php (1)
  • send (77-83)
includes/Notifications/WC/Base.php (1)
  • send (113-148)
includes/Notifications/WC/FailedAdmin.php (4)
texty.php (1)
  • Texty (20-152)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/WC/CancelledAdmin.php (1)
  • __construct (10-22)
includes/Notifications/WC/RefundedAdmin.php (1)
  • __construct (10-22)
includes/Notifications/Dokan/FailedVendor.php (3)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Integrations/Dokan.php (2)
  • Dokan (8-107)
  • __construct (13-17)
includes/Notifications/Dokan/CancelledVendor.php (1)
  • __construct (10-22)
includes/Notifications/WC/CancelledAdmin.php (3)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/WC/FailedAdmin.php (1)
  • __construct (10-22)
includes/Notifications/WC/RefundedAdmin.php (1)
  • __construct (10-22)
includes/Notifications/Dokan/CancelledVendor.php (4)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Integrations/Dokan.php (2)
  • Dokan (8-107)
  • __construct (13-17)
includes/Notifications/Dokan/FailedVendor.php (1)
  • __construct (10-22)
includes/Notifications/Dokan/RefundedVendor.php (1)
  • __construct (10-22)
includes/Notifications.php (1)
texty.php (1)
  • notifications (133-139)
includes/Notifications/WC/RefundedCustomer.php (4)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/WC/CancelledCustomer.php (1)
  • __construct (10-19)
includes/Notifications/WC/FailedCustomer.php (1)
  • __construct (10-19)
includes/Notifications/WC/RefundedAdmin.php (1)
  • __construct (10-22)
includes/Notifications/Dokan/RefundedVendor.php (4)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Integrations/Dokan.php (2)
  • Dokan (8-107)
  • __construct (13-17)
includes/Notifications/Dokan/CancelledVendor.php (1)
  • __construct (10-22)
includes/Notifications/Dokan/FailedVendor.php (1)
  • __construct (10-22)
includes/Notifications/WC/FailedCustomer.php (3)
includes/Notifications.php (1)
  • Notifications (8-117)
includes/Notifications/WC/CancelledCustomer.php (1)
  • __construct (10-19)
includes/Notifications/WC/RefundedCustomer.php (1)
  • __construct (10-19)
includes/Integrations/WooCommerce.php (2)
includes/Notifications/Notification.php (1)
  • send (257-281)
includes/Gateways/Twilio.php (1)
  • send (92-120)
🔇 Additional comments (14)
includes/Integrations/WooCommerce.php (1)

48-61: LGTM! Clean implementation of new order status notifications.

The three new cases (cancelled, failed, refunded) follow the existing pattern perfectly, dispatching both admin and customer notifications for each status. The implementation is consistent with the processing and completed status handlers.

includes/Notifications/WC/RefundedAdmin.php (1)

10-22: LGTM! Notification configuration matches PR objectives.

The constructor properly initializes all required properties with values that align with the PR requirements. The default message template correctly includes the expected placeholders: {order_id}, {billing_name}, {order_total}, and {site_name}.

includes/Notifications/WC/CancelledCustomer.php (1)

10-19: LGTM! Customer notification properly configured.

The constructor correctly sets type to 'user' for customer-facing notifications and uses the exact default message specified in the PR objectives. The implementation is consistent with other customer notification classes.

includes/Integrations/Dokan.php (1)

45-55: LGTM! Vendor notifications properly integrated.

The three new cases extend Dokan vendor notification support to cancelled, failed, and refunded statuses. The implementation correctly passes the vendor_id to ensure notifications reach the appropriate vendor, maintaining consistency with the existing processing and completed flows.

includes/Notifications/WC/FailedCustomer.php (1)

10-19: LGTM! Failed order customer notification properly configured.

The constructor initialization is clean and matches the PR specifications. The default message appropriately guides customers on next steps after a payment failure.

includes/Notifications/Dokan/CancelledVendor.php (1)

10-22: LGTM! Vendor notification follows established pattern.

The constructor properly initializes the notification with type set to 'vendor' and includes all necessary order details in the default message template. The implementation is consistent with other Dokan vendor notification classes.

includes/Notifications.php (3)

58-60: LGTM! Admin notification mappings properly registered.

The three new admin notification keys (cancelled, failed, refunded) are correctly mapped to their corresponding namespaced classes, following the existing registration pattern.


66-68: LGTM! Customer notification mappings properly registered.

The three new customer notification keys are correctly added alongside existing customer notifications, maintaining proper namespace references.


74-76: LGTM! Dokan vendor notification mappings properly registered.

The Dokan vendor notifications for cancelled, failed, and refunded statuses are correctly registered within the Dokan conditional block, ensuring they're only available when the Dokan plugin is active.

includes/Notifications/WC/FailedAdmin.php (1)

10-22: LGTM! Admin notification for failed orders properly configured.

The constructor initialization follows the established pattern for admin notifications, with appropriate default recipients and a message template that includes all relevant order failure details.

includes/Notifications/Dokan/FailedVendor.php (1)

1-23: LGTM! Consistent implementation for Dokan vendor notification.

The class correctly follows the established pattern for Dokan vendor notifications. The structure, naming, and default message template are consistent with sibling classes like CancelledVendor and align with the integration logic in includes/Integrations/Dokan.php.

includes/Notifications/Dokan/RefundedVendor.php (1)

1-23: LGTM! Well-structured Dokan vendor refund notification.

The implementation correctly mirrors the pattern established in CancelledVendor.php and FailedVendor.php. The default message appropriately labels the total as "Refund Amount" for clarity, and the class integrates properly with the Dokan status-change handlers.

includes/Notifications/WC/RefundedCustomer.php (1)

1-20: LGTM! Perfect alignment with PR requirements.

The implementation exactly matches the PR objectives for the customer refund notification. The title, message template, and class properties are all correct. The customer-friendly tone ("Hi {billing_name}...") is consistent with other customer notification classes.

includes/Notifications/WC/CancelledAdmin.php (1)

1-23: LGTM! Correctly implements admin cancelled order notification.

The class matches the PR objectives precisely, with the correct title, default recipients (administrator), and message template. The multi-line formatting of the default message improves SMS readability while maintaining all required template variables. The structure is consistent with FailedAdmin and RefundedAdmin classes.


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SMS Notifications for Cancelled, Failed, and Refunded Orders

2 participants