Changeset 3429456
- Timestamp:
- 12/30/2025 06:51:13 AM (8 weeks ago)
- Location:
- onwebchat/trunk
- Files:
-
- 3 edited
-
includes/woocommerce-sync.php (modified) (7 diffs)
-
onwebchat.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
onwebchat/trunk/includes/woocommerce-sync.php
r3429109 r3429456 279 279 private function send_product_batch($products) { 280 280 $chatId = get_option('onwebchat_plugin_option'); 281 $chatId = isset($chatId['text_string']) ? $chatId['text_string'] : '';281 $chatId = (is_array($chatId) && isset($chatId['text_string'])) ? $chatId['text_string'] : ''; 282 282 283 283 if (empty($chatId)) { … … 354 354 private function send_sync_completion_notification($total_stats) { 355 355 $chatId = get_option('onwebchat_plugin_option'); 356 $chatId = isset($chatId['text_string']) ? $chatId['text_string'] : '';356 $chatId = (is_array($chatId) && isset($chatId['text_string'])) ? $chatId['text_string'] : ''; 357 357 358 358 if (empty($chatId)) { … … 446 446 private function send_product_delete($product_id) { 447 447 $chatId = get_option('onwebchat_plugin_option'); 448 $chatId = isset($chatId['text_string']) ? $chatId['text_string'] : '';448 $chatId = (is_array($chatId) && isset($chatId['text_string'])) ? $chatId['text_string'] : ''; 449 449 450 450 if (empty($chatId)) { … … 492 492 public function request_secret_with_auth($email, $password) { 493 493 $chatId = get_option('onwebchat_plugin_option'); 494 $chatId = isset($chatId['text_string']) ? $chatId['text_string'] : '';494 $chatId = (is_array($chatId) && isset($chatId['text_string'])) ? $chatId['text_string'] : ''; 495 495 496 496 if (empty($chatId)) { … … 518 518 519 519 if (is_wp_error($response)) { 520 return array('success' => false, 'error' => $response->get_error_message()); 520 $error_message = $response->get_error_message(); 521 error_log('onWebChat WooCommerce Sync - Connection error: ' . $error_message); 522 return array('success' => false, 'error' => 'Connection failed: ' . $error_message); 521 523 } 522 524 523 525 $status_code = wp_remote_retrieve_response_code($response); 524 $body = json_decode(wp_remote_retrieve_body($response), true); 525 526 $response_body_raw = wp_remote_retrieve_body($response); 527 $body = json_decode($response_body_raw, true); 528 529 // Log response for debugging 530 error_log('onWebChat WooCommerce Sync - API response: Status=' . $status_code . ', Body=' . substr($response_body_raw, 0, 500)); 531 532 // Handle specific HTTP status codes 526 533 if ($status_code === 401) { 527 534 return array('success' => false, 'error' => 'Invalid email or password'); … … 532 539 } 533 540 541 // Success case 534 542 if ($status_code >= 200 && $status_code < 300 && isset($body['success']) && $body['success']) { 535 $secret = $body['secret']; 543 $secret = isset($body['secret']) ? $body['secret'] : null; 544 if (empty($secret)) { 545 error_log('onWebChat WooCommerce Sync - Success response but no secret provided'); 546 return array('success' => false, 'error' => 'Server response missing secret'); 547 } 536 548 update_option('onwebchat_wc_sync_secret', $secret); 537 549 return array('success' => true, 'secret' => $secret); 538 550 } 539 551 540 $error = isset($body['error']) ? $body['error'] : 'Unknown error'; 541 return array('success' => false, 'error' => $error); 552 // Extract error message from various possible response formats 553 $error_message = 'Unknown error'; 554 555 if (is_array($body)) { 556 // Try different possible error fields 557 if (isset($body['error'])) { 558 $error_message = is_string($body['error']) ? $body['error'] : json_encode($body['error']); 559 } elseif (isset($body['message'])) { 560 $error_message = is_string($body['message']) ? $body['message'] : json_encode($body['message']); 561 } elseif (isset($body['errors']) && is_array($body['errors'])) { 562 $error_message = implode(', ', $body['errors']); 563 } 564 } elseif (!empty($response_body_raw)) { 565 // If body is not JSON or empty, use raw response (truncated) 566 $error_message = 'Server returned: ' . substr(strip_tags($response_body_raw), 0, 200); 567 } 568 569 // Include status code in error message if not already included 570 if ($status_code && strpos($error_message, 'HTTP') === false) { 571 $error_message = 'HTTP ' . $status_code . ': ' . $error_message; 572 } 573 574 error_log('onWebChat WooCommerce Sync - Connection failed: ' . $error_message); 575 return array('success' => false, 'error' => $error_message); 542 576 } 543 577 … … 557 591 558 592 $chatId = get_option('onwebchat_plugin_option'); 559 $chatId = isset($chatId['text_string']) ? $chatId['text_string'] : '';593 $chatId = (is_array($chatId) && isset($chatId['text_string'])) ? $chatId['text_string'] : ''; 560 594 561 595 // Extract key part (before first slash if present) for consistency with server -
onwebchat/trunk/onwebchat.php
r3429109 r3429456 10 10 Description: Empower visitors with real-time human chat and integrated AI chatbots. onWebChat Live Chat delivers instant responses, smoother interactions, and 24/7 availability - improving engagement, satisfaction, and conversions. Includes WooCommerce product sync for AI training. 11 11 Author: onWebChat 12 Version: 3.5. 012 Version: 3.5.1 13 13 Author URI: https://www.onwebchat.com 14 14 */ … … 129 129 130 130 $options = get_option('onwebchat_plugin_option'); 131 $chatId = $options['text_string'];131 $chatId = (is_array($options) && isset($options['text_string'])) ? $options['text_string'] : ''; 132 132 //$hideWidget = get_option('onwebchat_plugin_option_hide'); 133 133 $hideWidget = false; 134 135 // If no chat ID is configured, don't output widget code 136 if (empty($chatId)) { 137 return; 138 } 134 139 135 140 $widgetCode = "<script type='text/javascript'>var onWebChat={ar:[], set: function(a,b){if (typeof onWebChat_==='undefined'){this.ar.push([a,b]);}else{onWebChat_.set(a,b);}},get:function(a){return(onWebChat_.get(a));},w:(function(){ var ga=document.createElement('script'); ga.type = 'text/javascript';ga.async=1;ga.src='//www.onwebchat.com/clientchat/$chatId';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})()}</script>"; -
onwebchat/trunk/readme.txt
r3429113 r3429456 5 5 Requires at least: 4.7 6 6 Requires PHP: 5.4 7 Stable tag: 3.5. 07 Stable tag: 3.5.1 8 8 License: GPLv2 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.