2 ) ); list( $aieo_wf_tm_open, $aieo_wf_tm_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'workflows-sending', 'icon' => 'send', 'title' => __( 'Sending', 'ai-eshop-optimizer' ), 'description' => __( 'Whether each channel sends nothing, sends to the testers only, or sends to every customer the workflows reach.', 'ai-eshop-optimizer' ), 'col' => 1, ) ); echo $aieo_wf_tm_open . AIEO_DMM_Workflows::sending_body() . $aieo_wf_tm_close; list( $aieo_wf_tm_open, $aieo_wf_tm_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'workflows-testers', 'icon' => 'user-round-check', 'title' => __( 'Testers', 'ai-eshop-optimizer' ), 'description' => __( 'The people who receive the workflows\' real messages and coupons while a channel is in Test.', 'ai-eshop-optimizer' ), 'col' => 2, 'footer' => \Rooster\Admin\Ui::button( __( 'Save testers', 'ai-eshop-optimizer' ), array( 'variant' => 'primary', 'attrs' => array( 'id' => 'aieo-wf-testers-save' ) ) ), ) ); echo $aieo_wf_tm_open . AIEO_DMM_Workflows::testers_body() . $aieo_wf_tm_close; rooster_admin_band_close(); } ?> 'workflows-campaigns-workflows', 'icon' => 'workflow', 'title' => __( 'Workflows', 'ai-eshop-optimizer' ), 'description' => __( 'The automated email and push sequences, what starts each one and whether it is active.', 'ai-eshop-optimizer' ), 'flush' => true, 'tools' => \Rooster\Admin\Ui::button( __( 'New workflow', 'ai-eshop-optimizer' ), array( 'size' => 'sm', 'icon' => 'plus', 'attrs' => array( 'id' => 'aieo-wf-new' ) ) ), ) ); echo $aieo_wf_open; ?> true, 'icon' => 'lock' ) ); ?>
'workflows-test-runs', 'icon' => 'flask-conical', 'title' => __( 'Test runs and coupons', 'ai-eshop-optimizer' ), 'description' => __( 'What the workflows did for the testers: each test run, and the real coupons minted for them.', 'ai-eshop-optimizer' ), 'flush' => true, 'footer' => \Rooster\Admin\Ui::button( __( 'Remove test coupons', 'ai-eshop-optimizer' ), array( 'variant' => 'destructive', 'attrs' => array( 'id' => 'aieo-wf-test-coupons-remove' ) + \Rooster\Admin\States::confirm_attrs( 'aieo-wf-test-coupons-dialog' ) ) ), ) ); echo $aieo_wf_tl_open . AIEO_DMM_Workflows::test_log_body() . $aieo_wf_tl_close; echo \Rooster\Admin\States::confirm( 'aieo-wf-test-coupons-dialog', 'delete', __( 'Remove every test coupon?', 'ai-eshop-optimizer' ), '

' . esc_html__( 'The testers\' coupons are deleted from WooCommerce, so their codes stop working. Customers\' coupons are not touched.', 'ai-eshop-optimizer' ) . '

', array( 'confirm' => __( 'Remove test coupons', 'ai-eshop-optimizer' ) ) ); echo \Rooster\Admin\Ui::dialog( 'aieo-wf-golive-dialog', __( 'Go live?', 'ai-eshop-optimizer' ), '

', array( 'footer' => \Rooster\Admin\Ui::button( __( 'Cancel them and go live', 'ai-eshop-optimizer' ), array( 'variant' => 'primary', 'attrs' => array( 'data-aieo-golive' => 'cancel' ) ) ) . ' ' . \Rooster\Admin\Ui::button( __( 'Keep the last 7 days\' and go live', 'ai-eshop-optimizer' ), array( 'attrs' => array( 'data-aieo-golive' => 'keep', 'id' => 'aieo-wf-golive-keep' ) ) ) . ' ' . \Rooster\Admin\Ui::button( __( 'Stay as it is', 'ai-eshop-optimizer' ), array( 'attrs' => array( 'data-ra-dialog-close' => '', 'data-aieo-golive' => 'stay' ) ) ), ) ); echo \Rooster\Admin\Ui::dialog( 'aieo-wf-tester-dialog', __( 'Run for a tester', 'ai-eshop-optimizer' ), '

' . esc_html__( 'A real run of this workflow for the tester, starting now: real messages on every channel they can receive, a real coupon locked to them, and real waits.', 'ai-eshop-optimizer' ) . '

' . '
' . \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-wf-tester-pick', 'label' => __( 'Tester', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', array(), '', array( 'id' => 'aieo-wf-tester-pick' ) ), ) ) . '
', array( 'form' => array( 'method' => 'dialog' ), 'confirm' => __( 'Run now', 'ai-eshop-optimizer' ), ) ); } ?> 'workflows-editor', 'icon' => 'pencil-line', 'title' => __( 'Edit workflow', 'ai-eshop-optimizer' ), 'attrs' => array( 'hidden' => true ), 'footer' => \Rooster\Admin\States::save_button( 'aieo-wf-editor', array( 'attrs' => array( 'id' => 'aieo-wf-save' ) ) ) . \Rooster\Admin\Ui::button( __( 'Cancel', 'ai-eshop-optimizer' ), array( 'attrs' => array( 'id' => 'aieo-wf-cancel' ) ) ), ) ); echo $aieo_wf_ed_open; ob_start(); ?>
'aieo-wf-name', 'label' => __( 'Name', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::input( '', '', array( 'id' => 'aieo-wf-name', 'medium' => true, 'autocomplete' => 'off', 'placeholder' => __( 'Workflow name…', 'ai-eshop-optimizer' ) ) ), ) ); ?>
'aieo-wf-editor' ) ); echo \Rooster\Admin\Ui::card_section( '1 · ' . __( 'Trigger', 'ai-eshop-optimizer' ), array( 'id' => 'aieo-wf-h-trigger' ) ); ?>
'aieo-wf-trigger', 'label' => __( 'Trigger', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', array(), '', array( 'id' => 'aieo-wf-trigger' ) ), 'help' => ' ', 'help_id' => 'aieo-wf-trigger-desc', ) ); ?>
'aieo-wf-h-audience' ) ); ?>
'aieo-wf-audience', 'label' => __( 'Audience', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', array(), '', array( 'id' => 'aieo-wf-audience' ) ), 'help' => __( 'Optional — restrict to a saved audience (from the Audience Builder). Otherwise everyone the trigger matches.', 'ai-eshop-optimizer' ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-wf-holdout-pct', 'label' => __( 'Holdout for incrementality', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', array( '0' => __( 'No holdout — send to everyone who matches', 'ai-eshop-optimizer' ), '5' => __( 'Hold back 5% as a control group', 'ai-eshop-optimizer' ), '10' => __( 'Hold back 10% as a control group', 'ai-eshop-optimizer' ), '20' => __( 'Hold back 20% as a control group', 'ai-eshop-optimizer' ), ), '0', array( 'id' => 'aieo-wf-holdout-pct' ) ), 'help' => __( 'A deterministic random slice is deliberately NOT messaged, so treated-vs-held-out conversion measures the campaign’s TRUE incremental lift (not just correlation). Excludes transactional flows (order receipt, back-in-stock).', 'ai-eshop-optimizer' ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'label' => '', 'control' => '' . '', ) ); ?>
'aieo', 'utm_medium' => 'email / push', 'utm_campaign' => 'wf_', 'utm_content' => __( 'campaign name', 'ai-eshop-optimizer' ), 'utm_term' => '—', ); foreach ( $aieo_wf_utm as $aieo_wf_key => $aieo_wf_ph ) { echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-wf-' . $aieo_wf_key, 'label' => $aieo_wf_key, 'control' => \Rooster\Admin\Ui::input( '', '', array( 'id' => 'aieo-wf-' . $aieo_wf_key, 'medium' => true, 'code' => true, 'autocomplete' => 'off', 'placeholder' => $aieo_wf_ph ) ), ) ); } ?>
, content=the campaign name). See the impact in the UTM Explorer + Attribution dashboard. Note: changing utm_campaign changes what Google Analytics attributes — Rooster One’s own coupon-revenue reporting is unaffected.', 'ai-eshop-optimizer' ) ); ?> 'aieo-wf-utm-fold' ) ); ?> 'aieo-wf-h-steps' ) ); ?> ', '', esc_html( AIEO_Campaign_I18n::DOMAIN ) ), 'info', array( 'inline' => true ) ); ?>
'sm', 'class' => 'aieo-wf-addstep', 'attrs' => array( 'data-type' => $k ) ) ); }; echo '
' . esc_html__( 'Add step', 'ai-eshop-optimizer' ) . ''; foreach ( $__primary as $__k ) { if ( isset( $__steps[ $__k ] ) ) { echo $__add( $__k, $__steps[ $__k ]['label'] ); } } echo '
'; $__rest = array_diff( array_keys( $__steps ), $__primary ); if ( $__rest ) { echo '
' . esc_html__( 'Add action — runs when the workflow is active (not gated by the channel engines)', 'ai-eshop-optimizer' ) . ''; foreach ( $__rest as $__k ) { echo $__add( $__k, $__steps[ $__k ]['label'] ); } echo '
'; } ?> __( 'Delete', 'ai-eshop-optimizer' ) ) ); echo $aieo_wf_dialog; ?> ' . \Rooster\Admin\Ui::field_row( array( 'id' => $prefix . '-step', 'label' => __( 'Send step', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', array(), '', array( 'id' => $prefix . '-step' ) ), ) ) . \Rooster\Admin\Ui::field_row( array( 'id' => $prefix . '-who', 'label' => __( 'With the data of', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::combo( '', array( '' => $any ), '', array( 'id' => $prefix . '-who', 'medium' => true, 'placeholder' => $any, 'search' => admin_url( 'admin-ajax.php' ) . '?action=aieo_wf_search_users&nonce=' . rawurlencode( $nonce ) . '&q={q}', 'items' => 'results', 'value_key' => 'value', 'label_key' => 'label', ) ), 'help' => __( 'Type a name or an e-mail address to use that customer\'s data; empty, the workflow picks one.', 'ai-eshop-optimizer' ), ) ) . ''; }; echo \Rooster\Admin\Ui::dialog( 'aieo-wf-preview-dialog', __( 'Preview', 'ai-eshop-optimizer' ), $aieo_wf_pickers( 'aieo-wf-preview' ) . '

' . '' . '', array( 'wide' => true, 'confirm' => '', 'cancel' => __( 'Close', 'ai-eshop-optimizer' ), ) ); echo \Rooster\Admin\Ui::dialog( 'aieo-wf-test-dialog', __( 'Send a test of this campaign', 'ai-eshop-optimizer' ), '

' . esc_html__( 'Delivered to this address only: it bypasses the paused engine and the opt-out list. An offer\'s coupon is a preview coupon, locked to this address.', 'ai-eshop-optimizer' ) . '

' . $aieo_wf_pickers( 'aieo-wf-test' ) . '
' . \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-wf-test-email', 'label' => __( 'Email', 'ai-eshop-optimizer' ), 'required' => true, 'control' => \Rooster\Admin\Ui::input( '', wp_get_current_user() ? (string) wp_get_current_user()->user_email : '', array( 'type' => 'email', 'id' => 'aieo-wf-test-email', 'required' => true, 'autocomplete' => 'email', 'medium' => true ) ), ) ) . '
', array( 'form' => array( 'method' => 'dialog' ), 'confirm' => __( 'Send test', 'ai-eshop-optimizer' ), ) ); echo AIEO_DMM_Workflows::rule_pickers( $nonce, array( 'term_brand' => isset( $brand_tax ) ? $brand_tax : 'product_brand', 'term_tag' => isset( $tag_tax ) ? $tag_tax : 'product_tag', 'term_need' => isset( $need_tax ) ? $need_tax : 'pa_need', ) ); wp_add_inline_script( 'aieo-workflows-admin', 'window.aieoWorkflows = ' . wp_json_encode( array( 'ajax' => admin_url( 'admin-ajax.php' ), 'nonce' => $nonce, 'testEmail' => wp_get_current_user() ? (string) wp_get_current_user()->user_email : '', 'triggers' => $triggers, 'steps' => $steps, 'audiences' => $audiences, 'orf' => isset( $order_rule_fields ) ? $order_rule_fields : array(), 'roles' => isset( $roles ) ? $roles : array(), 'deleteTitle' => __( 'Delete the workflow “%s”?', 'ai-eshop-optimizer' ), 'preview' => array( 'subject' => __( 'Subject: %s', 'ai-eshop-optimizer' ), 'none' => __( '(none)', 'ai-eshop-optimizer' ), 'target' => __( 'Rendered with real data from %s', 'ai-eshop-optimizer' ), 'coupon' => __( 'Coupon %s', 'ai-eshop-optimizer' ), 'failed' => __( 'Preview failed.', 'ai-eshop-optimizer' ), 'step' => __( 'Step %1$d: %2$s', 'ai-eshop-optimizer' ), 'push' => __( 'Push notification: %1$s · %2$s', 'ai-eshop-optimizer' ), ), 'tm' => array( 'failed' => __( 'That did not work. Reload the page and try again.', 'ai-eshop-optimizer' ), 'saved' => __( 'Saved.', 'ai-eshop-optimizer' ), 'noTesters' => __( 'Add a tester first, in the Testers card.', 'ai-eshop-optimizer' ), 'runFor' => __( 'Run “%s” for a tester', 'ai-eshop-optimizer' ), ), 'test' => array( 'sent' => __( 'Test sent to %s.', 'ai-eshop-optimizer' ), 'failed' => __( 'Test send failed.', 'ai-eshop-optimizer' ), 'invalid' => __( 'Enter an email address.', 'ai-eshop-optimizer' ), ), 'ed' => array( 'nameIt' => __( 'Name the workflow.', 'ai-eshop-optimizer' ), 'saveFailed' => __( 'Save failed.', 'ai-eshop-optimizer' ), 'moveUp' => __( 'Move up', 'ai-eshop-optimizer' ), 'remove' => __( 'Remove', 'ai-eshop-optimizer' ), 'removeCond' => __( 'Remove condition', 'ai-eshop-optimizer' ), 'addCond' => __( 'Add condition', 'ai-eshop-optimizer' ), 'field' => __( 'Field', 'ai-eshop-optimizer' ), 'comparison' => __( 'Comparison', 'ai-eshop-optimizer' ), 'value' => _x( 'Value', 'the value of a field', 'ai-eshop-optimizer' ), 'noSteps' => __( 'No steps yet', 'ai-eshop-optimizer' ), 'noStepsText' => __( 'Add a Wait or a Send below.', 'ai-eshop-optimizer' ), 'orderRules' => __( 'Order rules', 'ai-eshop-optimizer' ), 'onlyFire' => __( 'Only fire for orders matching', 'ai-eshop-optimizer' ), 'matchAll' => _x( 'ALL', 'order rules: an order matches all of them', 'ai-eshop-optimizer' ), 'matchAny' => _x( 'ANY', 'order rules: an order matches any of them', 'ai-eshop-optimizer' ), 'ofThese' => __( 'of these (leave empty = every order):', 'ai-eshop-optimizer' ), 'ops' => array( 'includes' => _x( 'includes', 'an order rule: the order holds the value', 'ai-eshop-optimizer' ), 'not_includes' => _x( 'does not include', 'an order rule: the order does not hold the value', 'ai-eshop-optimizer' ), 'is' => __( 'is', 'ai-eshop-optimizer' ), 'is_not' => __( 'is not', 'ai-eshop-optimizer' ), ), 'choose' => array( 'product' => __( 'Choose products', 'ai-eshop-optimizer' ), 'term_brand' => __( 'Choose brands', 'ai-eshop-optimizer' ), 'term_tag' => __( 'Choose tags', 'ai-eshop-optimizer' ), 'term_need' => __( 'Choose needs', 'ai-eshop-optimizer' ), 'term_cat' => __( 'Choose categories', 'ai-eshop-optimizer' ), ), 'none' => __( '— none —', 'ai-eshop-optimizer' ), 'everyone' => __( 'Everyone the trigger matches', 'ai-eshop-optimizer' ), ), 'i18n' => array( 'error' => __( 'Could not load workflows — check the connection and reload.', 'ai-eshop-optimizer' ), 'sent' => __( 'sent', 'ai-eshop-optimizer' ), 'opn' => __( 'opn', 'ai-eshop-optimizer' ), 'clk' => __( 'clk', 'ai-eshop-optimizer' ), 'red' => __( 'red', 'ai-eshop-optimizer' ), 'funnelTip' => __( 'Sent → email opens (rate) → clicks (CTR) → coupons redeemed · attributed revenue', 'ai-eshop-optimizer' ), 'active' => __( 'Active', 'ai-eshop-optimizer' ), 'messages' => __( 'Messages sent', 'ai-eshop-optimizer' ), 'opens' => __( 'Email opens', 'ai-eshop-optimizer' ), 'clicks' => __( 'Clicks', 'ai-eshop-optimizer' ), 'redeemed' => __( 'Coupons redeemed', 'ai-eshop-optimizer' ), 'revenue' => __( 'Attributed revenue', 'ai-eshop-optimizer' ), 'revenueHint' => __( 'Orders that used an automation\'s coupon or came last through its link, each order once.', 'ai-eshop-optimizer' ), 'edit' => __( 'Edit', 'ai-eshop-optimizer' ), 'pause' => __( 'Pause', 'ai-eshop-optimizer' ), 'activate' => __( 'Activate', 'ai-eshop-optimizer' ), 'preview' => __( 'Preview', 'ai-eshop-optimizer' ), 'test' => __( 'Send test', 'ai-eshop-optimizer' ), 'run' => __( 'Run now', 'ai-eshop-optimizer' ), 'del' => __( 'Delete workflow?', 'ai-eshop-optimizer' ), 'enqueued' => __( 'Runs started: %d. The messages leave within the hour.', 'ai-eshop-optimizer' ), 'status' => array( 'active' => __( 'active', 'ai-eshop-optimizer' ), 'paused' => __( 'paused', 'ai-eshop-optimizer' ), 'draft' => __( 'draft', 'ai-eshop-optimizer' ), ), ), ) ) . ';', 'before' );