'aiflt-abandoned-carts', 'session_id' => $aiflt_session_id], admin_url('admin.php'));
$aiflt_rc_log = $aiflt_rrow ? json_decode((string) $aiflt_rrow['log'], true) : [];
$aiflt_rc_log = is_array($aiflt_rc_log) ? $aiflt_rc_log : [];
$aiflt_rc_when = static function ($mysql) {
return $mysql ? wp_date(get_option('date_format') . ' ' . get_option('time_format'), strtotime((string) $mysql)) : '';
};
$aiflt_rc_phone = (string) ($aiflt_rrow['phone'] ?? '') !== '' ? (string) $aiflt_rrow['phone'] : (string) ($aiflt_cart['customer_phone'] ?? '');
$aiflt_rc_declined = ($aiflt_rrow && ($aiflt_rrow['status'] === 'unsubscribed' || $aiflt_rrow['stop_reason'] === 'declined'))
|| AIFLT_Cart_Recovery::is_opted_out($aiflt_rc_email, $aiflt_session_id);
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display-only flag after a redirect.
$aiflt_rc_wa_error = !empty($aiflt_is_open) && isset($_GET['aiflt_wa_error']) ? sanitize_key(wp_unslash($_GET['aiflt_wa_error'])) : '';
?>
'WhatsApp', 'sms' => 'SMS'];
foreach ($aiflt_rc_log as $aiflt_ev) :
$aiflt_ev_text = '';
switch ($aiflt_ev['e'] ?? '') {
case 'sent':
$aiflt_ev_names = [];
foreach ((array) ($aiflt_ev['via'] ?? []) as $aiflt_ch) {
$aiflt_ev_names[] = $aiflt_ch === 'email' ? __('email', 'ai-flash-tune') : ($aiflt_rc_channels[$aiflt_ch] ?? $aiflt_ch);
}
$aiflt_ev_text = array_diff((array) ($aiflt_ev['via'] ?? []), ['email'])
/* translators: 1: reminder number, 2: how it went out, such as "email, WhatsApp" */
? sprintf(__('Reminder %1$d sent (%2$s)', 'ai-flash-tune'), (int) ($aiflt_ev['step'] ?? 0), implode(', ', $aiflt_ev_names))
/* translators: %d: reminder number */
: sprintf(__('Reminder %d sent', 'ai-flash-tune'), (int) ($aiflt_ev['step'] ?? 0));
break;
case 'failed':
if (!empty($aiflt_ev['ch'])) {
/* translators: 1: channel such as "WhatsApp", 2: reminder number */
$aiflt_ev_text = sprintf(__('%1$s reminder %2$d could not be sent', 'ai-flash-tune'), $aiflt_rc_channels[$aiflt_ev['ch']] ?? $aiflt_ev['ch'], (int) ($aiflt_ev['step'] ?? 0));
break;
}
$aiflt_ev_text = (int) ($aiflt_ev['step'] ?? 0) > 0
/* translators: %d: reminder number */
? sprintf(__('Reminder %d could not be sent', 'ai-flash-tune'), (int) $aiflt_ev['step'])
: __('The saved-cart email could not be sent', 'ai-flash-tune');
break;
case 'opened':
$aiflt_ev_text = (int) ($aiflt_ev['step'] ?? 0) > 0
/* translators: %d: reminder number */
? sprintf(__('Opened reminder %d', 'ai-flash-tune'), (int) $aiflt_ev['step'])
: __('Opened the saved-cart email', 'ai-flash-tune');
break;
case 'saved':
$aiflt_ev_text = ($aiflt_ev['where'] ?? '') === 'exit'
? __('Asked for their cart by email (popup)', 'ai-flash-tune')
: __('Asked for their cart by email (cart page)', 'ai-flash-tune');
break;
case 'imported':
$aiflt_ev_text = sprintf(
/* translators: 1: plugin name, 2: number of emails it had sent */
__('Imported from %1$s (%2$d reminders sent there)', 'ai-flash-tune'),
['wcal' => 'Abandoned Cart Lite', 'funnelkit' => 'FunnelKit'][$aiflt_ev['from'] ?? ''] ?? 'CartFlows',
(int) ($aiflt_ev['sent'] ?? 0)
);
break;
case 'whatsapp':
$aiflt_ev_text = __('WhatsApp opened with the cart link', 'ai-flash-tune');
break;
case 'clicked':
$aiflt_ev_text = __('Opened their cart from a reminder', 'ai-flash-tune');
break;
case 'recovered':
/* translators: %d: order number */
$aiflt_ev_text = sprintf(__('Ordered: order #%d', 'ai-flash-tune'), (int) ($aiflt_ev['order'] ?? 0));
break;
}
if ($aiflt_ev_text === '') {
continue;
}
?>
get_edit_order_url()) . '">' . esc_html__('Open the order', 'ai-flash-tune') . '';
}
?>