get_option('onwebchat_wc_last_bulk_sync', 0), 'in_progress' => get_option('onwebchat_wc_bulk_in_progress', false), 'done' => get_option('onwebchat_wc_bulk_done', 0), 'total' => get_option('onwebchat_wc_bulk_total', 0), 'last_sync_start' => get_option('onwebchat_wc_last_sync_start', 0), ); // Calculate cooldown status $cooldown_period = 5 * 60; // 5 minutes // 5min // 5 * 60 //also in the file woocommerce-sync.php $time_since_last_sync = time() - $sync_status['last_sync_start']; $is_in_cooldown = ($time_since_last_sync < $cooldown_period) && $sync_status['last_sync_start'] > 0; $cooldown_remaining = $is_in_cooldown ? ceil(($cooldown_period - $time_since_last_sync) / 60) : 0; ?>

WooCommerce settings saved successfully!

⚠️ WooCommerce Sync Authentication Error:

This usually happens when:

Solution: Please enter your onWebChat account credentials again in the "Connect WooCommerce Sync" section below and click "Connect WooCommerce Sync" button to reconnect.

WooCommerce Product Sync

Let your AI chatbot understand your WooCommerce products. When enabled, products are automatically synced and kept up to date, allowing the AI to answer product-related questions accurately.

🔐 Connect WooCommerce Sync

To enable WooCommerce sync, please enter your onWebChat account credentials below.

Choose how product descriptions are synced for AI training

Connection Status ✓ Connected to onWebChat

WooCommerce sync is securely connected. Click "Disconnect" to re-authenticate.


AI Order Status Lookup

Let your AI chatbot answer "where is my order?" with live data. The store verifies identity using the order number and email (signed-in users only need the order number) before sharing details.


Bulk Sync Status

publish)) ? (int) $owc_counts->publish : 0; $owc_needs_selection = $owc_published_count > $owc_threshold; $owc_over_max = $owc_published_count > $owc_max; // Saved sync scope (product_cat term IDs) to pre-tick in the picker. $owc_saved_scope = array(); $owc_scope_raw = (string) get_option('onwebchat_wc_sync_categories', ''); if ($owc_scope_raw !== '') { foreach (explode(',', $owc_scope_raw) as $owc_sid) { $owc_sid = (int) trim($owc_sid); if ($owc_sid > 0) { $owc_saved_scope[] = $owc_sid; } } } $owc_categories = $owc_needs_selection ? get_terms(array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', )) : array(); if (is_wp_error($owc_categories)) { $owc_categories = array(); } // Build the category tree. The picker only offers top-level categories, and // selecting one covers its whole subtree, so each row shows a distinct product // count spanning the category and all of its descendants. $owc_children = array(); // parent_id => array of term objects foreach ($owc_categories as $owc_term) { $owc_children[(int) $owc_term->parent][] = $owc_term; } // Distinct published products in a category and its whole subtree. Counting // distinct posts (WP_Query found_posts with include_children) avoids the // over-count you get from summing per-term counts when a product is assigned // to both a parent and a child category. if (!function_exists('owc_subtree_product_count')) { function owc_subtree_product_count($term_id) { $query = new WP_Query(array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => 1, 'fields' => 'ids', 'no_found_rows' => false, 'tax_query' => array(array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => (int) $term_id, 'include_children' => true, )), )); return (int) $query->found_posts; } } // Renderable top-level categories (parent 0) that actually cover products. $owc_top_rows = array(); $owc_top_level = isset($owc_children[0]) ? $owc_children[0] : array(); foreach ($owc_top_level as $owc_term) { $owc_count = owc_subtree_product_count((int) $owc_term->term_id); if ($owc_count > 0) { $owc_top_rows[] = array('term' => $owc_term, 'count' => $owc_count); } } ?>

Choose what to sync

⏳ Sync in progress: / products synced

0): ?>

✓ Last bulk sync:

Total products synced:

No bulk sync has been performed yet.

Bulk sync was completed recently. Your products are already up to date, and any new or updated products will be synced automatically. Bulk sync was completed recently. Your products are already up to date. Please enable "Automatically sync products to onWebChat for AI training" above to keep all your products synced automatically. Click to sync all existing products. This process runs in the background and may take several minutes depending on your product count.

= total OR in progress for more than 3 minutes) $stuck_sync = $sync_status['in_progress'] && ( $sync_status['done'] >= $sync_status['total'] || (time() - $sync_status['last_sync_start'] > 180) ); if ($stuck_sync): ?>

If sync appears stuck, try processing manually or reset status.