| @@ -69,9 +69,9 @@ | ||
| 69 | 69 | <p><strong>Solution:</strong> Please enter your onWebChat account credentials again in the "Connect WooCommerce Sync" section below and click "Connect WooCommerce Sync" button to reconnect.</p> |
| 70 | 70 | </div> |
| 71 | 71 | <?php endif; ?> |
| 72 | 72 | |
| 73 | - <h2>WooCommerce Product Sync</h2> | |
| 73 | + <h2>Product Sync for the AI Chatbot</h2> | |
| 74 | 74 | <p> |
| 75 | 75 | Let your AI chatbot understand your WooCommerce products. |
| 76 | 76 | When enabled, products are automatically synced and kept up to date, allowing the AI to answer product-related questions accurately. |
| 77 | 77 | </p> |
| @@ -550,9 +550,9 @@ | ||
| 550 | 550 | No bulk sync has been performed yet. |
| 551 | 551 | </p> |
| 552 | 552 | <?php endif; ?> |
| 553 | 553 | |
| 554 | - <?php if ($owc_scope_summary && ($owc_scope_summary['categories'] > 0 || $sync_status['last_sync'] > 0)): ?> | |
| 554 | + <?php if ($owc_scope_summary && !empty($owc_scope_summary['known'])): ?> | |
| 555 | 555 | <p id="onwebchat_scope_summary" style="margin: 10px 0 0 0; color: #666;"> |
| 556 | 556 | <strong>In your AI training data:</strong> |
| 557 | 557 | <?php if ($owc_scope_summary['whole_catalogue']): ?> |
| 558 | 558 | <?php printf( |
| @@ -558,8 +558,10 @@ | ||
| 558 | 558 | <?php printf( |
| 559 | 559 | 'your whole catalogue (%s products)', |
| 560 | 560 | esc_html(number_format_i18n($owc_scope_summary['products'])) |
| 561 | 561 | ); ?> |
| 562 | + <?php elseif (!empty($owc_scope_summary['nothing'])): ?> | |
| 563 | + no products yet | |
| 562 | 564 | <?php else: ?> |
| 563 | 565 | <?php printf( |
| 564 | 566 | '%s %s, %s products', |
| 565 | 567 | esc_html(number_format_i18n($owc_scope_summary['categories'])), |
| @@ -658,8 +660,11 @@ | ||
| 658 | 660 | var owcHasPicker = $('#owc-category-picker').length > 0; |
| 659 | 661 | // The categories already in the AI training data. A sync only ever ADDS to |
| 660 | 662 | // this, so it is also the list a removal is measured against. |
| 661 | 663 | var owcSavedScope = <?php echo wp_json_encode(array_map('strval', $owc_saved_scope)); ?>; |
| 664 | + // Nothing in the training data yet: every ticked category is a first sync, | |
| 665 | + // so the button should not talk about what is "new" or a "re-sync". | |
| 666 | + var owcScopeNone = <?php echo (!empty($owc_scope_summary['nothing'])) ? 'true' : 'false'; ?>; | |
| 662 | 667 | var owcCatParent = {}; // category id => parent id ('0' for top-level categories) |
| 663 | 668 | var owcCatExplicit = {}; // category id => true when ticked by the merchant |
| 664 | 669 | var owcFiltering = false; |
| 665 | 670 | |
| @@ -752,8 +757,10 @@ | ||
| 752 | 757 | var added = owcAddedCategories().length; |
| 753 | 758 | var label; |
| 754 | 759 | if (!selected && !owcOverMax) { |
| 755 | 760 | label = 'Sync All Products Now'; |
| 761 | + } else if (owcScopeNone) { | |
| 762 | + label = 'Sync selected ' + (selected === 1 ? 'category' : 'categories'); | |
| 756 | 763 | } else if (added > 0) { |
| 757 | 764 | label = 'Sync ' + added + (added === 1 ? ' new category' : ' new categories'); |
| 758 | 765 | } else { |
| 759 | 766 | label = 'Re-sync selected categories'; |
| @@ -1044,8 +1051,12 @@ | ||
| 1044 | 1051 | success: function(response) { |
| 1045 | 1052 | if (!response || !response.success) { owcSyncFail((response && response.data) || 'Could not start sync'); return; } |
| 1046 | 1053 | var total = response.data.total || 0; |
| 1047 | 1054 | owcSyncProgress(0, total); |
| 1055 | + // Starting a sync switches automatic sync on server-side; show it. | |
| 1056 | + if (response.data.auto_sync_enabled) { | |
| 1057 | + $('#onwebchat_wc_sync_enabled').prop('checked', true); | |
| 1058 | + } | |
| 1048 | 1059 | if (total === 0) { |
| 1049 | 1060 | alert('No products found to sync.'); |
| 1050 | 1061 | $btn.prop('disabled', false); |
| 1051 | 1062 | owcUpdateSyncButtonLabel(); |