checkout()) { echo '
'; AIFLT_UI::empty_state('card', __('WooCommerce is not active', 'ai-flash-tune'), __('Activate WooCommerce to check your checkout.', 'ai-flash-tune')); echo '
'; return; } $aiflt_fields = []; foreach ((array) WC()->checkout()->get_checkout_fields() as $aiflt_section => $aiflt_group) { foreach ((array) $aiflt_group as $aiflt_key => $aiflt_field) { $aiflt_classes = (array) ($aiflt_field['class'] ?? []); if (array_intersect($aiflt_classes, ['hidden', 'form-row-hidden', 'form-row-none'])) { continue; } $aiflt_fields[] = [ 'key' => (string) $aiflt_key, 'section' => $aiflt_section, 'label' => wp_strip_all_tags((string) ($aiflt_field['label'] ?? $aiflt_key)), 'status' => !empty($aiflt_field['required']) ? 'required' : 'optional', ]; } } $aiflt_shown = count($aiflt_fields); $aiflt_required = count(array_filter($aiflt_fields, static function ($f) { return $f['status'] === 'required'; })); // Fields hidden through WooCommerce's own checkout settings, so the list shows what was taken away. $aiflt_hideable = [ 'billing_company' => ['woocommerce_checkout_company_field', __('Company name', 'ai-flash-tune')], 'billing_address_2' => ['woocommerce_checkout_address_2_field', __('Apartment, suite, unit, etc.', 'ai-flash-tune')], 'billing_phone' => ['woocommerce_checkout_phone_field', __('Phone', 'ai-flash-tune')], ]; $aiflt_listed = wp_list_pluck($aiflt_fields, 'key'); $aiflt_hidden = []; foreach ($aiflt_hideable as $aiflt_key => [$aiflt_option, $aiflt_label]) { if (!in_array($aiflt_key, $aiflt_listed, true) && get_option($aiflt_option) === 'hidden') { $aiflt_hidden[] = ['key' => $aiflt_key, 'section' => 'billing', 'label' => $aiflt_label, 'status' => 'hidden']; } } if ($aiflt_hidden) { // Show them at the end of the billing fields. $aiflt_at = count(array_filter($aiflt_fields, static function ($f) { return $f['section'] === 'billing'; })); array_splice($aiflt_fields, $aiflt_at, 0, $aiflt_hidden); } $aiflt_section_labels = [ 'billing' => __('Billing', 'ai-flash-tune'), 'shipping' => __('Shipping', 'ai-flash-tune'), 'account' => __('Account', 'ai-flash-tune'), 'order' => __('Order', 'ai-flash-tune'), ]; $aiflt_status_badges = [ 'required' => [__('Required', 'ai-flash-tune'), 'neutral'], 'optional' => [__('Optional', 'ai-flash-tune'), 'good'], 'hidden' => [__('Hidden', 'ai-flash-tune'), 'accent'], ]; // Classic shortcode or block checkout. $aiflt_checkout_type = __('Unknown', 'ai-flash-tune'); $aiflt_checkout_post = get_post((int) wc_get_page_id('checkout')); if ($aiflt_checkout_post) { if (has_block('woocommerce/checkout', $aiflt_checkout_post)) { $aiflt_checkout_type = __('Block checkout', 'ai-flash-tune'); } elseif (has_shortcode((string) $aiflt_checkout_post->post_content, 'woocommerce_checkout')) { $aiflt_checkout_type = __('Classic checkout', 'ai-flash-tune'); } } $aiflt_funnel = AIFLT_Funnel_Analyzer_Logic::get_funnel_data('all', gmdate('Y-m-d', current_time('timestamp') - 29 * DAY_IN_SECONDS), gmdate('Y-m-d', current_time('timestamp'))); $aiflt_abandon = AIFLT_Leak_Scan::checkout_abandonment($aiflt_funnel); $aiflt_has_data = empty($aiflt_funnel['is_empty']) && $aiflt_abandon !== null; ?>
15 ? esc_html__('more than most stores need', 'ai-flash-tune') : esc_html__('a reasonable number', 'ai-flash-tune'), $aiflt_shown > 15 ? 'leak' : '' ); AIFLT_UI::stat(__('Required', 'ai-flash-tune'), esc_html(number_format_i18n($aiflt_required)), esc_html__('must be filled in', 'ai-flash-tune')); AIFLT_UI::stat( __('Left at checkout', 'ai-flash-tune'), $aiflt_has_data ? esc_html(number_format_i18n((float) $aiflt_abandon, 0)) . '%' : '—', $aiflt_has_data ? esc_html__('last 30 days', 'ai-flash-tune') : esc_html__('no checkout visits yet', 'ai-flash-tune') ); AIFLT_UI::stat(__('Checkout type', 'ai-flash-tune'), '' . esc_html($aiflt_checkout_type) . '', esc_html__('as set on your checkout page', 'ai-flash-tune')); ?>

' . esc_html__('Appearance › Customize › WooCommerce › Checkout', 'ai-flash-tune') . '' ); ?>

→

>