' . esc_html__( 'WooCommerce is not active. This tab is only available when WooCommerce is installed and activated.', 'ai-search' ) . '

'; return; } // Get current settings $woocommerce_fields = get_option( 'ai_search_woocommerce_fields', $this->get_default_woocommerce_fields() ); $available_fields = $this->get_woocommerce_fields(); $product_attributes = $this->get_product_attributes(); /* * Store status (v1.32.0): one query per figure, all counting published * products only - the same population the search actually looks at. */ global $wpdb; $wc_total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'product' AND post_status = 'publish'" ); $wc_indexed = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} p INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = '_ai_search_embedding' WHERE p.post_type = 'product' AND p.post_status = 'publish'" ); $wc_with_sku = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} p INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = '_sku' WHERE p.post_type = 'product' AND p.post_status = 'publish' AND pm.meta_value <> ''" ); $wc_variations = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'product_variation' AND post_status = 'publish'" ); // Products the store hides from search results. $wc_hidden = 0; if ( function_exists( 'wc_get_product_visibility_term_ids' ) ) { $visibility_ids = wc_get_product_visibility_term_ids(); if ( ! empty( $visibility_ids['exclude-from-search'] ) ) { $wc_hidden = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->term_relationships} tr INNER JOIN {$wpdb->posts} p ON p.ID = tr.object_id WHERE tr.term_taxonomy_id = %d AND p.post_type = 'product' AND p.post_status = 'publish'", $visibility_ids['exclude-from-search'] ) ); } } // Term embeddings power category/tag matching for products. $wc_terms_enabled = (bool) get_option( 'ai_search_term_embeddings_enabled', true ); $wc_terms_total = 0; $wc_terms_indexed = 0; if ( $wc_terms_enabled ) { $wc_terms_total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE taxonomy IN ( 'product_cat', 'product_tag' )" ); $wc_terms_indexed = (int) $wpdb->get_var( "SELECT COUNT(DISTINCT tt.term_id) FROM {$wpdb->term_taxonomy} tt INNER JOIN {$wpdb->termmeta} tm ON tm.term_id = tt.term_id AND tm.meta_key = '_ai_search_term_embedding' WHERE tt.taxonomy IN ( 'product_cat', 'product_tag' )" ); } $wc_missing = max( 0, $wc_total - $wc_indexed ); $wc_missing_terms = max( 0, $wc_terms_total - $wc_terms_indexed ); $wc_sku_enabled = in_array( 'product_sku', (array) $woocommerce_fields, true ); ?>

0 ) : ?> 0 ) : ?>
0 ) : ?>  
0 && ! $wc_sku_enabled ) : ?>  
0 ) : ?>  
0 && 0 === $wc_indexed ) : ?>

$field_label ) : ?>

$field_label ) : ?>

attribute_name; ?>