Redesign email settings with granular per-email toggles and cashier notifications#502
Redesign email settings with granular per-email toggles and cashier notifications#502
Conversation
…hier notifications Replaces flat boolean admin_emails/customer_emails settings with nested arrays supporting master toggles and individual per-email-type control. Adds cashier_emails category so POS cashiers can receive new_order notifications independently of admin settings. Key changes: - Settings structure migrated from bool to array with backwards compat - new_order recipients controlled via recipient filter (not enabled filter) so admin and cashier toggles work independently - Cashier identified from _pos_user order meta - Dedup prevents duplicate emails when cashier is also admin Closes #430
📝 WalkthroughWalkthroughCheckout email settings changed from booleans to structured arrays (admin, customer, cashier); API validation updated to accept arrays; emails handler adds cashier recipient filtering and per-email enablement; settings service migrates legacy boolean values; tests expanded for cashier behavior and migration. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant REST as REST API\n(includes/API/Settings.php)
participant Settings as Settings Service\n(includes/Services/Settings.php)
participant Order as POS Order
participant Emails as Emails Handler\n(includes/Emails.php)
participant Mailer as WooCommerce Mailer
Client->>REST: GET/PUT checkout settings (includes `cashier_emails`)
REST->>Settings: validate & migrate settings
Settings-->>REST: return structured checkout settings
Client->>Order: Create POS order (includes _pos_user / cashier id)
Order->>Emails: Trigger new_order flow
Emails->>Settings: read admin/customer/cashier toggles
Emails->>Emails: get_cashier_email(order)
Emails->>Mailer: assemble recipient list (admin + cashier if enabled, dedupe)
Mailer-->>Emails: send(new_order)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
E2E API Test Results35 tests 35 ✅ 3s ⏱️ Results for commit febac8e. ♻️ This comment has been updated with latest results. |
PHPUnit Test Results696 tests +17 688 ✅ +18 56s ⏱️ +4s Results for commit febac8e. ± Comparison against base commit 29e6290. This pull request removes 14 and adds 31 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…rmat - Replace stdClass mocks with WC_Email mocks in Test_Emails so instanceof checks pass and individual toggle tests work correctly - Update Test_Settings_API and Test_Settings_Service assertions to expect the new array format for email settings instead of booleans - Fix all PHPCS lint errors in both settings test files
- Fix test_new_order_recipients_dedup_cashier_is_admin: use existing admin user instead of creating a new one (WP rejects duplicate emails) - Fix test_new_order_recipients_cashier_no_email: create user with valid email then wipe via DB (WP rejects empty emails during user creation) - Fix test_email_id_extraction_from_wc_email: instantiate WC_Email_Customer_Processing_Order directly instead of relying on the mailer which is reset in setUp
PR #502 added per-email-type controls and cashier emails to the backend, but the frontend still rendered simple boolean toggles. This updates the checkout settings page to surface the full email settings structure with master toggles and individual email type checkboxes.
Summary
Closes #430
woocommerce_email_recipient_new_orderfilter (not the enabled filter) so admin and cashier new_order toggles work independentlySettings structure
new_order,cancelled_order,failed_ordercustomer_on_hold_order,customer_processing_order,customer_completed_order,customer_refunded_order,customer_failed_ordernew_order(cashier identified from_pos_userorder meta)Test plan
woocommerce_pos_admin_email_enabled,woocommerce_pos_customer_email_enabled)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests