[ 'label' => __('Checkout Order Created', 'afroit-messaging-workflows'), 'accepted_args' => 1, ], 'new_order' => [ 'label' => 'New Order', 'accepted_args' => 2, ], // 2. Order Status Change Hooks 'checkout_update_order_meta' => [ 'label' => __('Checkout Update Order Meta', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_changed' => [ 'label' => __('Order Status Changed', 'afroit-messaging-workflows'), 'accepted_args' => 4, ], 'order_status_processing' => [ 'label' => __('Order Status: Processing', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_cancelled' => [ 'label' => __('Order Status: Cancelled', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_refunded' => [ 'label' => __('Order Status: Refunded', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_pending' => [ 'label' => __('Order Status: Pending', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'checkout_order_processed' => [ 'label' => __('Checkout Order Processed', 'afroit-messaging-workflows'), 'accepted_args' => 3, ], 'store_api_checkout_order_processed' => [ 'label' => __('Store API Checkout Order Processed', 'afroit-messaging-workflows'), 'accepted_args' => 1, ], // 3. Payment Hooks 'order_status_pending_to_cancelled' => [ 'label' => __('Order Status Changed: Pending to Cancelled', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_completed' => [ 'label' => __('Order Status: Completed', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'order_status_failed' => [ 'label' => __('Payment Failed', 'afroit-messaging-workflows'), 'accepted_args' => 2, ], 'payment_complete' => [ 'label' => __('Payment Complete', 'afroit-messaging-workflows'), 'accepted_args' => 1, ], // 4. Cart Hooks (Critical for Revenue) 'add_to_cart' => [ 'label' => __('Add To Cart', 'afroit-messaging-workflows'), 'accepted_args' => 6, ], 'cart_updated' => [ 'label' => __('Cart Updated', 'afroit-messaging-workflows'), 'accepted_args' => 0, ], // 5. User Registration Hooks 'created_customer' => [ 'label' => __('Created Customer', 'afroit-messaging-workflows'), 'accepted_args' => 3, ], // 6. Coupon Hooks 'applied_coupon' => [ 'label' => __('Applied Coupon', 'afroit-messaging-workflows'), 'accepted_args' => 1, ], // 7. Product Purchase Hooks 'order_item_added' => [ 'label' => __('Order Item Added', 'afroit-messaging-workflows'), 'accepted_args' => 3, ], 'thankyou' => [ 'label' => __('Thank You Page', 'afroit-messaging-workflows'), 'accepted_args' => 1, ], // 8. The "Abandonment" Trigger (via Cron Job) 'cart_abandoned' => [ 'label' => __('Shopping Cart Abandoned', 'afroit-messaging-workflows'), 'accepted_args' => 0, ], ]; /** * Filter the workflow trigger registry. * * @param array $triggers Trigger map. */ $filtered = apply_filters( 'afromewo_workflow_triggers', $triggers ); return is_array( $filtered ) ? $filtered : $triggers; } private static function getRegisteredTriggers(): array { $repository = new \AfroIT\Messaging\WorkflowAutomations\Workflows\WorkflowRepository(); $triggers = $repository->getUniqueTriggers(); $all = self::getTriggers(); $registered = []; foreach ($triggers as $trigger) { if (isset($all[$trigger])) { $registered[$trigger] = $all[$trigger]; } } return $registered; } }