Changeset 3792437
- Timestamp:
- 11/09/2026 12:23:46 PM (12 days ago)
- Location:
- sell-ai-chatbot-for-woocommerce
- Files:
-
- 20 edited
- 1 copied
-
tags/1.5.3 (copied) (copied from sell-ai-chatbot-for-woocommerce/trunk )
-
tags/1.5.3/includes/class-sellai-ajax.php (modified) (1 diff)
-
tags/1.5.3/includes/class-sellai-conversations.php (modified) (5 diffs)
-
tags/1.5.3/includes/class-sellai-i18n.php (modified) (10 diffs)
-
tags/1.5.3/includes/class-sellai-product-context.php (modified) (6 diffs)
-
tags/1.5.3/includes/class-sellai-prompt-presets.php (modified) (1 diff)
-
tags/1.5.3/includes/pro-bridge/class-sellai-hook-extension-points.php (modified) (1 diff)
-
tags/1.5.3/public/css/chatbot.css (modified) (1 diff)
-
tags/1.5.3/public/js/chatbot.js (modified) (3 diffs)
-
tags/1.5.3/readme.txt (modified) (3 diffs)
-
tags/1.5.3/sell-ai.php (modified) (2 diffs)
-
trunk/includes/class-sellai-ajax.php (modified) (1 diff)
-
trunk/includes/class-sellai-conversations.php (modified) (5 diffs)
-
trunk/includes/class-sellai-i18n.php (modified) (10 diffs)
-
trunk/includes/class-sellai-product-context.php (modified) (6 diffs)
-
trunk/includes/class-sellai-prompt-presets.php (modified) (1 diff)
-
trunk/includes/pro-bridge/class-sellai-hook-extension-points.php (modified) (1 diff)
-
trunk/public/css/chatbot.css (modified) (1 diff)
-
trunk/public/js/chatbot.js (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/sell-ai.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-ajax.php
r3790000 r3792437 1733 1733 // 3. CTA enforcement — buy intent but no add-to-cart/checkout phrase 1734 1734 if ( $php_intent === 'buy' && ! preg_match( '/add to cart|dodaj do kosz|kup teraz|buy now|zamów|order now|checkout|przejdź do kasy/iu', $reply ) ) { 1735 $append .= ' ' . SellAI_I18n::get( 'cta_order' ); 1735 // The CTA names the cart button exactly as the widget shows it. 1736 $append .= ' ' . sprintf( SellAI_I18n::get( 'cta_order' ), trim( SellAI_I18n::get( 'btn_add_cart' ) ) ); 1736 1737 } 1737 1738 -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-conversations.php
r3739994 r3792437 263 263 $transcript = mb_substr( $transcript, 0, 3000 ); 264 264 265 $prompt = "Summarize this chat in 1-2 sentences. Focus on: what product the customer was looking for, any specific requirements (price, specs), and outcome (found/not found/added to cart). Be concise. Reply in English regardless of original language.\n\nConversation:\n{$transcript}"; 266 267 $summary = trim( SellAI_OpenAI::chat_simple( $prompt, 'gpt-5-mini', 120 ) ); 268 if ( ! $summary ) return false; 269 270 // Detect intent from summary keywords 271 $intent = self::detect_intent_from_summary( $summary, $history ); 265 // The summary is shown to the customer ("Your previous conversations"), 266 // so it is written in the chat language; the intent comes as a tag. 267 $language = self::summary_language(); 268 $prompt = "Summarize this chat in 1-2 short sentences for the customer, in {$language}. Focus on: what product the customer was looking for, any specific requirements (price, specs), and outcome (found/not found/added to cart). Be concise. Do not mention the assistant's internal tags.\n" 269 . "On a last separate line write exactly one tag: INTENT:ordered, INTENT:wishlist, INTENT:comparing, INTENT:interested or INTENT:browsing.\n\nConversation:\n{$transcript}"; 270 271 $raw = trim( SellAI_OpenAI::chat_simple( $prompt, 'gpt-5-mini', 160 ) ); 272 if ( ! $raw ) return false; 273 274 $tag = ''; 275 if ( preg_match( '/\bINTENT:\s*(ordered|wishlist|comparing|interested|browsing)\b/i', $raw, $m ) ) { 276 $tag = strtolower( $m[1] ); 277 } 278 $summary = trim( (string) preg_replace( '/\s*\bINTENT:\s*\w*\s*/i', ' ', $raw ) ); 279 if ( $summary === '' ) return false; 280 281 // The tag; without it, the keyword detection (English summaries). 282 $intent = $tag !== '' ? self::intent_from_actions( $history, $tag ) : self::detect_intent_from_summary( $summary, $history ); 272 283 273 284 global $wpdb; … … 280 291 ); 281 292 return true; 293 } 294 295 /** 296 * Language name of the chat widget, for the summary prompt. 297 */ 298 private static function summary_language(): string { 299 $names = [ 300 'pl' => 'Polish', 'de' => 'German', 'fr' => 'French', 'es' => 'Spanish', 'it' => 'Italian', 301 'nl' => 'Dutch', 'cs' => 'Czech', 'pt' => 'Portuguese', 'sv' => 'Swedish', 'en' => 'English', 302 ]; 303 $lang = strtolower( substr( SellAI_I18n::get_locale(), 0, 2 ) ); 304 return $names[ $lang ] ?? 'the language of the conversation'; 305 } 306 307 /** 308 * Intent from the model's tag; cart / wishlist directives in the 309 * conversation win, as in detect_intent_from_summary(). 310 */ 311 private static function intent_from_actions( array $history, string $tag ): string { 312 foreach ( array_slice( $history, -6 ) as $msg ) { 313 $content = is_string( $msg['content'] ?? null ) ? $msg['content'] : ''; 314 if ( strpos( $content, 'ADD_TO_CART' ) !== false ) return 'ordered'; 315 if ( strpos( $content, 'ADD_TO_WISHLIST' ) !== false ) return 'wishlist'; 316 } 317 return $tag; 282 318 } 283 319 … … 353 389 foreach ( $rows as &$row ) { 354 390 $row['products'] = self::get_product_summaries( $row['product_ids'] ); 355 $row['ago'] = self::human_time_diff( $row['last_message_at'] ); 391 $row['ago'] = self::human_time_diff( $row['last_message_at'], true ); 392 $row['ago_en'] = self::human_time_diff( $row['last_message_at'] ); 356 393 } 357 394 return $rows; … … 376 413 } 377 414 378 private static function human_time_diff( string $mysql_date ): string { 415 /** 416 * "5m ago" (English, for the AI prompt) or, with $localized, the chat 417 * language text shown in the history panel ("5 min temu"). 418 */ 419 private static function human_time_diff( string $mysql_date, bool $localized = false ): string { 379 420 $diff = time() - strtotime( $mysql_date ); 380 if ( $diff < 60 ) return 'just now'; 381 if ( $diff < 3600 ) return round( $diff / 60 ) . 'm ago'; 382 if ( $diff < 86400 ) return round( $diff / 3600 ) . 'h ago'; 383 if ( $diff < 86400 * 30 ) return round( $diff / 86400 ) . 'd ago'; 384 return gmdate( 'd.m.Y', strtotime( $mysql_date ) ); 421 if ( $diff >= 86400 * 30 ) return gmdate( 'd.m.Y', strtotime( $mysql_date ) ); 422 if ( ! $localized ) { 423 if ( $diff < 60 ) return 'just now'; 424 if ( $diff < 3600 ) return round( $diff / 60 ) . 'm ago'; 425 if ( $diff < 86400 ) return round( $diff / 3600 ) . 'h ago'; 426 return round( $diff / 86400 ) . 'd ago'; 427 } 428 if ( $diff < 60 ) return SellAI_I18n::get( 'history_just_now' ); 429 if ( $diff < 3600 ) return sprintf( SellAI_I18n::get( 'history_min_ago' ), (int) round( $diff / 60 ) ); 430 if ( $diff < 86400 ) return sprintf( SellAI_I18n::get( 'history_hours_ago' ), (int) round( $diff / 3600 ) ); 431 return sprintf( SellAI_I18n::get( 'history_days_ago' ), (int) round( $diff / 86400 ) ); 385 432 } 386 433 … … 622 669 foreach ( $history as $conv ) { 623 670 if ( ! $conv['summary'] ) continue; 624 $lines[] = "- [{$conv['ago ']}] {$conv['summary']}";671 $lines[] = "- [{$conv['ago_en']}] {$conv['summary']}"; 625 672 } 626 673 if ( empty( $lines ) ) return ''; -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-i18n.php
r3739994 r3792437 61 61 'history_title' => '📋 Your previous conversations', 62 62 'history_no_summary' => 'Conversation without summary', 63 'history_just_now' => 'just now', 64 'history_min_ago' => '%d min ago', 65 'history_hours_ago' => '%d h ago', 66 'history_days_ago' => '%d days ago', 67 'history_msgs' => '%d msg', 63 68 'history_load_btn' => 'Load conversation →', 64 69 'history_loading' => 'Loading...', 65 70 'cart_upsell' => 'I see you already have items in your cart — want to complete your order or add something extra?', 66 'cta_order' => 'Ready to order? Click " Add to cart" to proceed!',71 'cta_order' => 'Ready to order? Click "%s" to proceed!', 67 72 'service_unavailable' => 'The assistant is temporarily unavailable. Please try again later.', 68 73 'error_message_too_long' => 'Your message is too long. Please shorten it to 1000 characters.', … … 128 133 'history_title' => '📋 Twoje poprzednie rozmowy', 129 134 'history_no_summary' => 'Rozmowa bez podsumowania', 135 'history_just_now' => 'przed chwilą', 136 'history_min_ago' => '%d min temu', 137 'history_hours_ago' => '%d godz. temu', 138 'history_days_ago' => '%d dni temu', 139 'history_msgs' => '%d wiad.', 130 140 'history_load_btn' => 'Wczytaj rozmowę →', 131 141 'history_loading' => 'Wczytywanie...', 132 142 'cart_upsell' => 'Widzę, że masz już produkty w koszyku — chcesz sfinalizować zamówienie lub dodać coś jeszcze?', 133 'cta_order' => 'Gotowy do zakupu? Kliknij „ Dodaj do koszyka"!',143 'cta_order' => 'Gotowy do zakupu? Kliknij „%s”!', 134 144 'service_unavailable' => 'Asystent jest chwilowo niedostępny. Spróbuj ponownie później.', 135 145 'error_message_too_long' => 'Wiadomość jest za długa. Skróć ją do 1000 znaków.', … … 195 205 'history_title' => '📋 Ihre früheren Gespräche', 196 206 'history_no_summary' => 'Gespräch ohne Zusammenfassung', 207 'history_just_now' => 'gerade eben', 208 'history_min_ago' => 'vor %d Min.', 209 'history_hours_ago' => 'vor %d Std.', 210 'history_days_ago' => 'vor %d Tagen', 211 'history_msgs' => '%d Nachr.', 197 212 'history_load_btn' => 'Gespräch laden →', 198 213 'history_loading' => 'Laden...', 199 214 'cart_upsell' => 'Sie haben bereits Artikel im Warenkorb — möchten Sie Ihre Bestellung abschließen oder etwas hinzufügen?', 200 'cta_order' => 'Bereit zum Bestellen? Klicken Sie auf „ In den Warenkorb"!',215 'cta_order' => 'Bereit zum Bestellen? Klicken Sie auf „%s“!', 201 216 'service_unavailable' => 'Der Assistent ist vorübergehend nicht verfügbar. Bitte versuchen Sie es später erneut.', 202 217 'error_message_too_long' => 'Ihre Nachricht ist zu lang. Bitte kürzen Sie sie auf 1000 Zeichen.', … … 262 277 'history_title' => '📋 Vos conversations précédentes', 263 278 'history_no_summary' => 'Conversation sans résumé', 279 'history_just_now' => 'à l\'instant', 280 'history_min_ago' => 'il y a %d min', 281 'history_hours_ago' => 'il y a %d h', 282 'history_days_ago' => 'il y a %d jours', 283 'history_msgs' => '%d msg', 264 284 'history_load_btn' => 'Charger la conversation →', 265 285 'history_loading' => 'Chargement...', 266 286 'cart_upsell' => 'Vous avez déjà des articles dans votre panier — souhaitez-vous finaliser ou ajouter autre chose ?', 267 'cta_order' => 'Prêt à commander ? Cliquez sur « Ajouter au panier» !',287 'cta_order' => 'Prêt à commander ? Cliquez sur « %s » !', 268 288 'service_unavailable' => 'L\'assistant est temporairement indisponible. Veuillez réessayer plus tard.', 269 289 'error_message_too_long' => 'Votre message est trop long. Veuillez le réduire à 1000 caractères.', … … 329 349 'history_title' => '📋 Tus conversaciones anteriores', 330 350 'history_no_summary' => 'Conversación sin resumen', 351 'history_just_now' => 'ahora mismo', 352 'history_min_ago' => 'hace %d min', 353 'history_hours_ago' => 'hace %d h', 354 'history_days_ago' => 'hace %d días', 355 'history_msgs' => '%d mens.', 331 356 'history_load_btn' => 'Cargar conversación →', 332 357 'history_loading' => 'Cargando...', 333 358 'cart_upsell' => 'Ya tienes artículos en tu carrito — ¿quieres completar tu pedido o añadir algo más?', 334 'cta_order' => '¿Listo para pedir? ¡Haz clic en " Añadir al carrito"!',359 'cta_order' => '¿Listo para pedir? ¡Haz clic en "%s"!', 335 360 'service_unavailable' => 'El asistente no está disponible temporalmente. Inténtalo de nuevo más tarde.', 336 361 'error_message_too_long' => 'Tu mensaje es demasiado largo. Acórtalo a 1000 caracteres.', … … 396 421 'history_title' => '📋 Le tue conversazioni precedenti', 397 422 'history_no_summary' => 'Conversazione senza riepilogo', 423 'history_just_now' => 'poco fa', 424 'history_min_ago' => '%d min fa', 425 'history_hours_ago' => '%d ore fa', 426 'history_days_ago' => '%d giorni fa', 427 'history_msgs' => '%d msg', 398 428 'history_load_btn' => 'Carica conversazione →', 399 429 'history_loading' => 'Caricamento...', 400 430 'cart_upsell' => 'Hai già articoli nel carrello — vuoi completare l\'ordine o aggiungere qualcos\'altro?', 401 'cta_order' => 'Pronto per ordinare? Clicca su " Aggiungi al carrello"!',431 'cta_order' => 'Pronto per ordinare? Clicca su "%s"!', 402 432 'service_unavailable' => 'L\'assistente non è temporaneamente disponibile. Riprova più tardi.', 403 433 'error_message_too_long' => 'Il messaggio è troppo lungo. Riducilo a 1000 caratteri.', … … 462 492 'rate_limit_hour' => 'Te veel berichten. Wacht even voordat u een nieuw bericht stuurt.', 463 493 'cart_upsell' => 'Je hebt al artikelen in je winkelwagen — wil je je bestelling afronden of iets toevoegen?', 464 'cta_order' => 'Klaar om te bestellen? Klik op " Toevoegen aan winkelwagen"!',494 'cta_order' => 'Klaar om te bestellen? Klik op "%s"!', 465 495 'service_unavailable' => 'De assistent is tijdelijk niet beschikbaar. Probeer het later opnieuw.', 466 496 'error_message_too_long' => 'Je bericht is te lang. Kort het in tot 1000 tekens.', … … 525 555 'rate_limit_hour' => 'Příliš mnoho zpráv. Počkejte chvíli před odesláním další.', 526 556 'cart_upsell' => 'Máte již zboží v košíku — chcete objednávku dokončit nebo přidat něco dalšího?', 527 'cta_order' => 'Připraveni objednat? Klikněte na „ Přidat do košíku"!',557 'cta_order' => 'Připraveni objednat? Klikněte na „%s“!', 528 558 'service_unavailable' => 'Asistent je dočasně nedostupný. Zkuste to prosím později.', 529 559 'error_message_too_long' => 'Zpráva je příliš dlouhá. Zkraťte ji na 1000 znaků.', … … 588 618 'rate_limit_hour' => 'Demasiadas mensagens. Por favor, aguarde um momento.', 589 619 'cart_upsell' => 'Você já tem itens no carrinho — quer finalizar o pedido ou adicionar mais algo?', 590 'cta_order' => 'Pronto para pedir? Clique em " Adicionar ao carrinho"!',620 'cta_order' => 'Pronto para pedir? Clique em "%s"!', 591 621 'service_unavailable' => 'O assistente está temporariamente indisponível. Tente novamente mais tarde.', 592 622 'error_message_too_long' => 'A sua mensagem é demasiado longa. Reduza-a para 1000 caracteres.', … … 651 681 'rate_limit_hour' => 'För många meddelanden. Vänta en stund innan du skickar igen.', 652 682 'cart_upsell' => 'Du har redan varor i kundvagnen — vill du slutföra din beställning eller lägga till något mer?', 653 'cta_order' => 'Redo att beställa? Klicka på " Lägg i kundvagn"!',683 'cta_order' => 'Redo att beställa? Klicka på "%s"!', 654 684 'service_unavailable' => 'Assistenten är tillfälligt otillgänglig. Försök igen senare.', 655 685 'error_message_too_long' => 'Ditt meddelande är för långt. Korta det till 1000 tecken.', -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-product-context.php
r3739994 r3792437 185 185 $p .= "- Never hallucinate. Use ONLY data from the PRODUCT CATALOG.\n"; 186 186 $p .= "- Always move toward a purchase decision — every response should bring the customer closer to buying.\n"; 187 $p .= "- NEVER claim you have added a product to the cart or performed any shop action. The customer clicks the buttons themselves. Say \"Click 'Add to cart'\" — NEVER \"I added it to your cart\".\n\n"; 187 // Name the cart button exactly as the widget shows it (in the chat language). 188 $cart_label = str_replace( [ '"', "\n" ], [ "'", ' ' ], SellAI_I18n::get( 'btn_add_cart' ) ); 189 $p .= "- NEVER claim you have added a product to the cart or performed any shop action. The customer clicks the buttons themselves. Say \"Click '{$cart_label}'\" — NEVER \"I added it to your cart\".\n"; 190 $p .= "- The add-to-cart button on the product cards is labelled \"{$cart_label}\". When you mention it, use exactly this label, never an English or translated variant.\n\n"; 188 191 189 192 self::cut( $sections, 'sales_mission', $p ); … … 205 208 $p .= "Rule 1: Every product in the catalog EXISTS and is REAL. Never deny its existence.\n"; 206 209 $p .= "Rule 2: The Stock field is authoritative. INSTOCK = available. OUTOFSTOCK = unavailable. Do not guess.\n"; 210 $p .= "Rule 2a: Catalog field names and codes (INSTOCK, OUTOFSTOCK, BACKORDER, PriceRaw, PICKUP-ONLY, ShippingClass, [PREV], [ID:…], OnSale:YES …) are internal. Never show them to the customer, not even in quotes: say it in plain words in the customer's language (e.g. 'available', 'in stock', 'out of stock', 'on backorder').\n"; 211 $p .= "Rule 2b: Never state dispatch or delivery times (\"ships tomorrow\", \"delivery in 1–2 days\") unless the catalog (ShipETA field) or the shop information in this prompt gives them. If they are not given, say you do not have the exact time and point to the product page or the shop's delivery information.\n"; 207 212 $p .= "Rule 3: Never invent products not in the catalog. Never claim a brand is absent if its products appear in the catalog.\n"; 208 213 $p .= "Rule 3a: BRAND QUERIES — CRITICAL: When a customer asks about a specific brand, you MUST NOT use your training knowledge to decide whether the store carries that brand. ONLY the PRODUCT CATALOG is authoritative. If the catalog contains products with that brand name in their title — the store SELLS that brand. Present those products immediately. NEVER say 'we don't carry [Brand]' or 'we don't have products from this brand' when products with that brand name appear in the catalog.\n"; … … 610 615 611 616 $p .= "## PRODUCT CATALOG\n"; 612 $p .= "Fields: [ID:xxx] [PREV?] Name | Price | PriceRaw | Stock | Categories | URL | OnSale | RegularPrice | Delivery | Dims | Weight | ShortDesc | Attributes \n";613 $p .= "[PREV] = shown to this customer in an earlier message. Stock: INSTOCK / OUTOFSTOCK / BACKORDER / INSTOCK(N units) \n";617 $p .= "Fields: [ID:xxx] [PREV?] Name | Price | PriceRaw | Stock | Categories | URL | OnSale | RegularPrice | Delivery | Dims | Weight | ShortDesc | Attributes | ShipETA (optional)\n"; 618 $p .= "[PREV] = shown to this customer in an earlier message. Stock: INSTOCK / OUTOFSTOCK / BACKORDER / INSTOCK(N units). Delivery:PICKUP-ONLY = personal pickup only.\n"; 614 619 if ( $catalog_count > 0 && self::$is_approximate ) { 615 620 $p .= "STATUS: {$catalog_count} APPROXIMATE match(es). No exact match found — these are the CLOSEST products the search engine returned.\n"; … … 1450 1455 } 1451 1456 1457 /** 1458 * Filters one product line of the catalog sent to the AI 1459 * ("[ID:12] Name | price | … | field:value"). Append " | Field:value" 1460 * parts; a line break or a removed "[ID:n]" prefix drops the change. 1461 * 1462 * @since 1.5.3 1463 * 1464 * @param string $line Catalog line. 1465 * @param WC_Product $product Product. 1466 */ 1467 $filtered = apply_filters( 'sellai_catalog_product_line', $line, $product ); 1468 if ( is_string( $filtered ) && strpos( $filtered, "[ID:{$id}]" ) === 0 && strpbrk( $filtered, "\r\n" ) === false ) { 1469 $line = mb_substr( $filtered, 0, mb_strlen( $line ) + 500 ); 1470 } 1471 1452 1472 $lines[] = $line; 1453 1473 } … … 2186 2206 } 2187 2207 2188 return[2208 $card = [ 2189 2209 'id' => $product_id, 2190 2210 'name' => html_entity_decode( $product->get_name(), ENT_QUOTES | ENT_HTML5, 'UTF-8' ), … … 2200 2220 'sku' => $product->get_sku(), 2201 2221 ]; 2222 2223 /** 2224 * Filters the extra fields of a product card in the chat. Only 2225 * 'delivery' is read: a plain-text line shown under the stock label 2226 * (e.g. "Ships today if you order by 14:00"); '' shows none. The 2227 * other fields cannot be changed here. 2228 * 2229 * @since 1.5.3 2230 * 2231 * @param array $extra [ 'delivery' => '' ]. 2232 * @param WC_Product $product Product. 2233 * @param array $card Card data (read only). 2234 */ 2235 $extra = apply_filters( 'sellai_product_card_extra', [ 'delivery' => '' ], $product, $card ); 2236 if ( is_array( $extra ) && isset( $extra['delivery'] ) && is_scalar( $extra['delivery'] ) ) { 2237 $delivery = trim( (string) preg_replace( '/\s+/u', ' ', wp_strip_all_tags( (string) $extra['delivery'] ) ) ); 2238 if ( $delivery !== '' ) { 2239 $card['delivery'] = mb_substr( $delivery, 0, 160 ); 2240 } 2241 } 2242 return $card; 2202 2243 } 2203 2244 -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-prompt-presets.php
r3739994 r3792437 48 48 ], 49 49 'sales' => [ 50 'directive' => 'Be persuasive and conversion-focused. Every response MUST end with a clear call to action (e.g. "Click Add to cart to get yours today").',50 'directive' => 'Be persuasive and conversion-focused. Every response MUST end with a clear call to action (e.g. tell them to click the add-to-cart button to get theirs today).', 51 51 'force_cta' => true, 52 52 'prompt_cards' => 1, -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/pro-bridge/class-sellai-hook-extension-points.php
r3790000 r3792437 62 62 * sellai_ab_testing_available ( bool $available = false ) Adds the sellai_ab cookie to the suggested privacy policy text (1.5.0, SellAI_Privacy). 63 63 * sellai_pre_chat_reply ( ?array $reply = null, string $message, array $context ) Answer a chat message before the FAQ and OpenAI: [ 'message', 'quick_replies'?, 'log_message'? ]; null continues as usual (1.5.2, SellAI_Ajax). 64 * sellai_catalog_product_line ( string $line, WC_Product $product ) One product line of the catalog sent to the AI; append " | Field:value" (1.5.3, SellAI_Product_Context). 65 * sellai_product_card_extra ( array $extra = [ 'delivery' => '' ], WC_Product $product, array $card ) Plain-text delivery line under the stock label of a chat product card (1.5.3, SellAI_Product_Context). 64 66 * 65 67 * ── Actions ───────────────────────────────────────────────────────── -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/public/css/chatbot.css
r3778395 r3792437 1382 1382 1383 1383 /* ── Stock status badges ── */ 1384 .sellai-pcard-delivery { 1385 display: block !important; 1386 margin-top: 3px !important; 1387 font-size: 11px !important; 1388 line-height: 1.35 !important; 1389 color: #475569 !important; 1390 } 1384 1391 .sellai-stock-ok { 1385 1392 display: inline-block !important; -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/public/js/chatbot.js
r3778395 r3792437 569 569 var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable')); 570 570 html += '<div class="' + (p.in_stock ? 'sellai-stock-ok' : 'sellai-stock-none') + '">' + esc(stockLabel) + '</div>'; 571 if (p.delivery) html += '<div class="sellai-pcard-delivery">' + esc(p.delivery) + '</div>'; 571 572 if (p.reason) html += '<div class="sellai-compare-reason">' + esc(p.reason) + '</div>'; 572 573 if (p.in_stock) { … … 627 628 var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable')); 628 629 html += '<div class="' + (p.in_stock ? 'sellai-stock-ok' : 'sellai-stock-none') + '">' + escName(stockLabel) + '</div>'; 630 if (p.delivery) html += '<div class="sellai-pcard-delivery">' + esc(p.delivery) + '</div>'; 629 631 630 632 if (p.reason) { … … 1356 1358 + '<span class="sellai-hist-icon">' + intent_icon + '</span>' 1357 1359 + '<span class="sellai-hist-ago">' + esc(conv.ago) + '</span>' 1358 + '<span class="sellai-hist-msgs">' + conv.message_count + ' msg</span>'1360 + '<span class="sellai-hist-msgs">' + esc(i18n('history_msgs').replace('%d', parseInt(conv.message_count, 10) || 0)) + '</span>' 1359 1361 + '</div>' 1360 1362 + '<div class="sellai-hist-summary">' + esc(conv.summary || i18n('history_no_summary')) + '</div>' -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/readme.txt
r3790000 r3792437 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.0 7 Stable tag: 1.5. 27 Stable tag: 1.5.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 202 202 203 203 == Changelog == 204 205 = 1.5.3 = 206 * Fix: the assistant could quote internal catalog codes such as "INSTOCK" to customers and guess dispatch or delivery times. It now describes availability in plain words and states delivery times only when the shop provides them. 207 * Fix: the assistant named the cart button "Add to cart" in English even in a Polish or German chat. It now uses the button label exactly as the widget shows it, also in the automatic "Ready to order?" call to action. 208 * Fix: in "Your previous conversations" the summaries are now written in the chat language (they were always in English), and "2d ago" / "3 msg" are translated. Summaries saved earlier stay as they are. 209 * Product cards in the chat can show a delivery line under the stock label (filled by add-ons such as Sell.AI Chatbot Pro with Sell.AI Stock, e.g. "Ships today if you order by 14:00"). Without an add-on nothing changes. 210 * For developers: new filters `sellai_catalog_product_line` (one product line of the catalog sent to the AI) and `sellai_product_card_extra` (delivery line of a product card). 204 211 205 212 = 1.5.2 = … … 302 309 == Upgrade Notice == 303 310 311 = 1.5.3 = 312 Adds the extension points that Sell.AI Pro 5.3 needs for delivery times in the chat. No changes for the free chatbot. 313 304 314 = 1.5.2 = 305 315 Adds the extension point that Sell.AI Pro 5.1 needs for order status in the chat. No changes for the free chatbot. -
sell-ai-chatbot-for-woocommerce/tags/1.5.3/sell-ai.php
r3790000 r3792437 4 4 * Plugin URI: https://trysellai.com 5 5 * Description: AI-powered sales chatbot for WooCommerce. Helps customers find products, answers questions and boosts conversions. Powered by OpenAI GPT-5. 6 * Version: 1.5. 26 * Version: 1.5.3 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 8.0 … … 21 21 if ( ! defined( 'ABSPATH' ) ) exit; 22 22 23 define( 'SELLAI_VERSION', '1.5. 2' );23 define( 'SELLAI_VERSION', '1.5.3' ); 24 24 define( 'SELLAI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 25 25 define( 'SELLAI_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-ajax.php
r3790000 r3792437 1733 1733 // 3. CTA enforcement — buy intent but no add-to-cart/checkout phrase 1734 1734 if ( $php_intent === 'buy' && ! preg_match( '/add to cart|dodaj do kosz|kup teraz|buy now|zamów|order now|checkout|przejdź do kasy/iu', $reply ) ) { 1735 $append .= ' ' . SellAI_I18n::get( 'cta_order' ); 1735 // The CTA names the cart button exactly as the widget shows it. 1736 $append .= ' ' . sprintf( SellAI_I18n::get( 'cta_order' ), trim( SellAI_I18n::get( 'btn_add_cart' ) ) ); 1736 1737 } 1737 1738 -
sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-conversations.php
r3739994 r3792437 263 263 $transcript = mb_substr( $transcript, 0, 3000 ); 264 264 265 $prompt = "Summarize this chat in 1-2 sentences. Focus on: what product the customer was looking for, any specific requirements (price, specs), and outcome (found/not found/added to cart). Be concise. Reply in English regardless of original language.\n\nConversation:\n{$transcript}"; 266 267 $summary = trim( SellAI_OpenAI::chat_simple( $prompt, 'gpt-5-mini', 120 ) ); 268 if ( ! $summary ) return false; 269 270 // Detect intent from summary keywords 271 $intent = self::detect_intent_from_summary( $summary, $history ); 265 // The summary is shown to the customer ("Your previous conversations"), 266 // so it is written in the chat language; the intent comes as a tag. 267 $language = self::summary_language(); 268 $prompt = "Summarize this chat in 1-2 short sentences for the customer, in {$language}. Focus on: what product the customer was looking for, any specific requirements (price, specs), and outcome (found/not found/added to cart). Be concise. Do not mention the assistant's internal tags.\n" 269 . "On a last separate line write exactly one tag: INTENT:ordered, INTENT:wishlist, INTENT:comparing, INTENT:interested or INTENT:browsing.\n\nConversation:\n{$transcript}"; 270 271 $raw = trim( SellAI_OpenAI::chat_simple( $prompt, 'gpt-5-mini', 160 ) ); 272 if ( ! $raw ) return false; 273 274 $tag = ''; 275 if ( preg_match( '/\bINTENT:\s*(ordered|wishlist|comparing|interested|browsing)\b/i', $raw, $m ) ) { 276 $tag = strtolower( $m[1] ); 277 } 278 $summary = trim( (string) preg_replace( '/\s*\bINTENT:\s*\w*\s*/i', ' ', $raw ) ); 279 if ( $summary === '' ) return false; 280 281 // The tag; without it, the keyword detection (English summaries). 282 $intent = $tag !== '' ? self::intent_from_actions( $history, $tag ) : self::detect_intent_from_summary( $summary, $history ); 272 283 273 284 global $wpdb; … … 280 291 ); 281 292 return true; 293 } 294 295 /** 296 * Language name of the chat widget, for the summary prompt. 297 */ 298 private static function summary_language(): string { 299 $names = [ 300 'pl' => 'Polish', 'de' => 'German', 'fr' => 'French', 'es' => 'Spanish', 'it' => 'Italian', 301 'nl' => 'Dutch', 'cs' => 'Czech', 'pt' => 'Portuguese', 'sv' => 'Swedish', 'en' => 'English', 302 ]; 303 $lang = strtolower( substr( SellAI_I18n::get_locale(), 0, 2 ) ); 304 return $names[ $lang ] ?? 'the language of the conversation'; 305 } 306 307 /** 308 * Intent from the model's tag; cart / wishlist directives in the 309 * conversation win, as in detect_intent_from_summary(). 310 */ 311 private static function intent_from_actions( array $history, string $tag ): string { 312 foreach ( array_slice( $history, -6 ) as $msg ) { 313 $content = is_string( $msg['content'] ?? null ) ? $msg['content'] : ''; 314 if ( strpos( $content, 'ADD_TO_CART' ) !== false ) return 'ordered'; 315 if ( strpos( $content, 'ADD_TO_WISHLIST' ) !== false ) return 'wishlist'; 316 } 317 return $tag; 282 318 } 283 319 … … 353 389 foreach ( $rows as &$row ) { 354 390 $row['products'] = self::get_product_summaries( $row['product_ids'] ); 355 $row['ago'] = self::human_time_diff( $row['last_message_at'] ); 391 $row['ago'] = self::human_time_diff( $row['last_message_at'], true ); 392 $row['ago_en'] = self::human_time_diff( $row['last_message_at'] ); 356 393 } 357 394 return $rows; … … 376 413 } 377 414 378 private static function human_time_diff( string $mysql_date ): string { 415 /** 416 * "5m ago" (English, for the AI prompt) or, with $localized, the chat 417 * language text shown in the history panel ("5 min temu"). 418 */ 419 private static function human_time_diff( string $mysql_date, bool $localized = false ): string { 379 420 $diff = time() - strtotime( $mysql_date ); 380 if ( $diff < 60 ) return 'just now'; 381 if ( $diff < 3600 ) return round( $diff / 60 ) . 'm ago'; 382 if ( $diff < 86400 ) return round( $diff / 3600 ) . 'h ago'; 383 if ( $diff < 86400 * 30 ) return round( $diff / 86400 ) . 'd ago'; 384 return gmdate( 'd.m.Y', strtotime( $mysql_date ) ); 421 if ( $diff >= 86400 * 30 ) return gmdate( 'd.m.Y', strtotime( $mysql_date ) ); 422 if ( ! $localized ) { 423 if ( $diff < 60 ) return 'just now'; 424 if ( $diff < 3600 ) return round( $diff / 60 ) . 'm ago'; 425 if ( $diff < 86400 ) return round( $diff / 3600 ) . 'h ago'; 426 return round( $diff / 86400 ) . 'd ago'; 427 } 428 if ( $diff < 60 ) return SellAI_I18n::get( 'history_just_now' ); 429 if ( $diff < 3600 ) return sprintf( SellAI_I18n::get( 'history_min_ago' ), (int) round( $diff / 60 ) ); 430 if ( $diff < 86400 ) return sprintf( SellAI_I18n::get( 'history_hours_ago' ), (int) round( $diff / 3600 ) ); 431 return sprintf( SellAI_I18n::get( 'history_days_ago' ), (int) round( $diff / 86400 ) ); 385 432 } 386 433 … … 622 669 foreach ( $history as $conv ) { 623 670 if ( ! $conv['summary'] ) continue; 624 $lines[] = "- [{$conv['ago ']}] {$conv['summary']}";671 $lines[] = "- [{$conv['ago_en']}] {$conv['summary']}"; 625 672 } 626 673 if ( empty( $lines ) ) return ''; -
sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-i18n.php
r3739994 r3792437 61 61 'history_title' => '📋 Your previous conversations', 62 62 'history_no_summary' => 'Conversation without summary', 63 'history_just_now' => 'just now', 64 'history_min_ago' => '%d min ago', 65 'history_hours_ago' => '%d h ago', 66 'history_days_ago' => '%d days ago', 67 'history_msgs' => '%d msg', 63 68 'history_load_btn' => 'Load conversation →', 64 69 'history_loading' => 'Loading...', 65 70 'cart_upsell' => 'I see you already have items in your cart — want to complete your order or add something extra?', 66 'cta_order' => 'Ready to order? Click " Add to cart" to proceed!',71 'cta_order' => 'Ready to order? Click "%s" to proceed!', 67 72 'service_unavailable' => 'The assistant is temporarily unavailable. Please try again later.', 68 73 'error_message_too_long' => 'Your message is too long. Please shorten it to 1000 characters.', … … 128 133 'history_title' => '📋 Twoje poprzednie rozmowy', 129 134 'history_no_summary' => 'Rozmowa bez podsumowania', 135 'history_just_now' => 'przed chwilą', 136 'history_min_ago' => '%d min temu', 137 'history_hours_ago' => '%d godz. temu', 138 'history_days_ago' => '%d dni temu', 139 'history_msgs' => '%d wiad.', 130 140 'history_load_btn' => 'Wczytaj rozmowę →', 131 141 'history_loading' => 'Wczytywanie...', 132 142 'cart_upsell' => 'Widzę, że masz już produkty w koszyku — chcesz sfinalizować zamówienie lub dodać coś jeszcze?', 133 'cta_order' => 'Gotowy do zakupu? Kliknij „ Dodaj do koszyka"!',143 'cta_order' => 'Gotowy do zakupu? Kliknij „%s”!', 134 144 'service_unavailable' => 'Asystent jest chwilowo niedostępny. Spróbuj ponownie później.', 135 145 'error_message_too_long' => 'Wiadomość jest za długa. Skróć ją do 1000 znaków.', … … 195 205 'history_title' => '📋 Ihre früheren Gespräche', 196 206 'history_no_summary' => 'Gespräch ohne Zusammenfassung', 207 'history_just_now' => 'gerade eben', 208 'history_min_ago' => 'vor %d Min.', 209 'history_hours_ago' => 'vor %d Std.', 210 'history_days_ago' => 'vor %d Tagen', 211 'history_msgs' => '%d Nachr.', 197 212 'history_load_btn' => 'Gespräch laden →', 198 213 'history_loading' => 'Laden...', 199 214 'cart_upsell' => 'Sie haben bereits Artikel im Warenkorb — möchten Sie Ihre Bestellung abschließen oder etwas hinzufügen?', 200 'cta_order' => 'Bereit zum Bestellen? Klicken Sie auf „ In den Warenkorb"!',215 'cta_order' => 'Bereit zum Bestellen? Klicken Sie auf „%s“!', 201 216 'service_unavailable' => 'Der Assistent ist vorübergehend nicht verfügbar. Bitte versuchen Sie es später erneut.', 202 217 'error_message_too_long' => 'Ihre Nachricht ist zu lang. Bitte kürzen Sie sie auf 1000 Zeichen.', … … 262 277 'history_title' => '📋 Vos conversations précédentes', 263 278 'history_no_summary' => 'Conversation sans résumé', 279 'history_just_now' => 'à l\'instant', 280 'history_min_ago' => 'il y a %d min', 281 'history_hours_ago' => 'il y a %d h', 282 'history_days_ago' => 'il y a %d jours', 283 'history_msgs' => '%d msg', 264 284 'history_load_btn' => 'Charger la conversation →', 265 285 'history_loading' => 'Chargement...', 266 286 'cart_upsell' => 'Vous avez déjà des articles dans votre panier — souhaitez-vous finaliser ou ajouter autre chose ?', 267 'cta_order' => 'Prêt à commander ? Cliquez sur « Ajouter au panier» !',287 'cta_order' => 'Prêt à commander ? Cliquez sur « %s » !', 268 288 'service_unavailable' => 'L\'assistant est temporairement indisponible. Veuillez réessayer plus tard.', 269 289 'error_message_too_long' => 'Votre message est trop long. Veuillez le réduire à 1000 caractères.', … … 329 349 'history_title' => '📋 Tus conversaciones anteriores', 330 350 'history_no_summary' => 'Conversación sin resumen', 351 'history_just_now' => 'ahora mismo', 352 'history_min_ago' => 'hace %d min', 353 'history_hours_ago' => 'hace %d h', 354 'history_days_ago' => 'hace %d días', 355 'history_msgs' => '%d mens.', 331 356 'history_load_btn' => 'Cargar conversación →', 332 357 'history_loading' => 'Cargando...', 333 358 'cart_upsell' => 'Ya tienes artículos en tu carrito — ¿quieres completar tu pedido o añadir algo más?', 334 'cta_order' => '¿Listo para pedir? ¡Haz clic en " Añadir al carrito"!',359 'cta_order' => '¿Listo para pedir? ¡Haz clic en "%s"!', 335 360 'service_unavailable' => 'El asistente no está disponible temporalmente. Inténtalo de nuevo más tarde.', 336 361 'error_message_too_long' => 'Tu mensaje es demasiado largo. Acórtalo a 1000 caracteres.', … … 396 421 'history_title' => '📋 Le tue conversazioni precedenti', 397 422 'history_no_summary' => 'Conversazione senza riepilogo', 423 'history_just_now' => 'poco fa', 424 'history_min_ago' => '%d min fa', 425 'history_hours_ago' => '%d ore fa', 426 'history_days_ago' => '%d giorni fa', 427 'history_msgs' => '%d msg', 398 428 'history_load_btn' => 'Carica conversazione →', 399 429 'history_loading' => 'Caricamento...', 400 430 'cart_upsell' => 'Hai già articoli nel carrello — vuoi completare l\'ordine o aggiungere qualcos\'altro?', 401 'cta_order' => 'Pronto per ordinare? Clicca su " Aggiungi al carrello"!',431 'cta_order' => 'Pronto per ordinare? Clicca su "%s"!', 402 432 'service_unavailable' => 'L\'assistente non è temporaneamente disponibile. Riprova più tardi.', 403 433 'error_message_too_long' => 'Il messaggio è troppo lungo. Riducilo a 1000 caratteri.', … … 462 492 'rate_limit_hour' => 'Te veel berichten. Wacht even voordat u een nieuw bericht stuurt.', 463 493 'cart_upsell' => 'Je hebt al artikelen in je winkelwagen — wil je je bestelling afronden of iets toevoegen?', 464 'cta_order' => 'Klaar om te bestellen? Klik op " Toevoegen aan winkelwagen"!',494 'cta_order' => 'Klaar om te bestellen? Klik op "%s"!', 465 495 'service_unavailable' => 'De assistent is tijdelijk niet beschikbaar. Probeer het later opnieuw.', 466 496 'error_message_too_long' => 'Je bericht is te lang. Kort het in tot 1000 tekens.', … … 525 555 'rate_limit_hour' => 'Příliš mnoho zpráv. Počkejte chvíli před odesláním další.', 526 556 'cart_upsell' => 'Máte již zboží v košíku — chcete objednávku dokončit nebo přidat něco dalšího?', 527 'cta_order' => 'Připraveni objednat? Klikněte na „ Přidat do košíku"!',557 'cta_order' => 'Připraveni objednat? Klikněte na „%s“!', 528 558 'service_unavailable' => 'Asistent je dočasně nedostupný. Zkuste to prosím později.', 529 559 'error_message_too_long' => 'Zpráva je příliš dlouhá. Zkraťte ji na 1000 znaků.', … … 588 618 'rate_limit_hour' => 'Demasiadas mensagens. Por favor, aguarde um momento.', 589 619 'cart_upsell' => 'Você já tem itens no carrinho — quer finalizar o pedido ou adicionar mais algo?', 590 'cta_order' => 'Pronto para pedir? Clique em " Adicionar ao carrinho"!',620 'cta_order' => 'Pronto para pedir? Clique em "%s"!', 591 621 'service_unavailable' => 'O assistente está temporariamente indisponível. Tente novamente mais tarde.', 592 622 'error_message_too_long' => 'A sua mensagem é demasiado longa. Reduza-a para 1000 caracteres.', … … 651 681 'rate_limit_hour' => 'För många meddelanden. Vänta en stund innan du skickar igen.', 652 682 'cart_upsell' => 'Du har redan varor i kundvagnen — vill du slutföra din beställning eller lägga till något mer?', 653 'cta_order' => 'Redo att beställa? Klicka på " Lägg i kundvagn"!',683 'cta_order' => 'Redo att beställa? Klicka på "%s"!', 654 684 'service_unavailable' => 'Assistenten är tillfälligt otillgänglig. Försök igen senare.', 655 685 'error_message_too_long' => 'Ditt meddelande är för långt. Korta det till 1000 tecken.', -
sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-product-context.php
r3739994 r3792437 185 185 $p .= "- Never hallucinate. Use ONLY data from the PRODUCT CATALOG.\n"; 186 186 $p .= "- Always move toward a purchase decision — every response should bring the customer closer to buying.\n"; 187 $p .= "- NEVER claim you have added a product to the cart or performed any shop action. The customer clicks the buttons themselves. Say \"Click 'Add to cart'\" — NEVER \"I added it to your cart\".\n\n"; 187 // Name the cart button exactly as the widget shows it (in the chat language). 188 $cart_label = str_replace( [ '"', "\n" ], [ "'", ' ' ], SellAI_I18n::get( 'btn_add_cart' ) ); 189 $p .= "- NEVER claim you have added a product to the cart or performed any shop action. The customer clicks the buttons themselves. Say \"Click '{$cart_label}'\" — NEVER \"I added it to your cart\".\n"; 190 $p .= "- The add-to-cart button on the product cards is labelled \"{$cart_label}\". When you mention it, use exactly this label, never an English or translated variant.\n\n"; 188 191 189 192 self::cut( $sections, 'sales_mission', $p ); … … 205 208 $p .= "Rule 1: Every product in the catalog EXISTS and is REAL. Never deny its existence.\n"; 206 209 $p .= "Rule 2: The Stock field is authoritative. INSTOCK = available. OUTOFSTOCK = unavailable. Do not guess.\n"; 210 $p .= "Rule 2a: Catalog field names and codes (INSTOCK, OUTOFSTOCK, BACKORDER, PriceRaw, PICKUP-ONLY, ShippingClass, [PREV], [ID:…], OnSale:YES …) are internal. Never show them to the customer, not even in quotes: say it in plain words in the customer's language (e.g. 'available', 'in stock', 'out of stock', 'on backorder').\n"; 211 $p .= "Rule 2b: Never state dispatch or delivery times (\"ships tomorrow\", \"delivery in 1–2 days\") unless the catalog (ShipETA field) or the shop information in this prompt gives them. If they are not given, say you do not have the exact time and point to the product page or the shop's delivery information.\n"; 207 212 $p .= "Rule 3: Never invent products not in the catalog. Never claim a brand is absent if its products appear in the catalog.\n"; 208 213 $p .= "Rule 3a: BRAND QUERIES — CRITICAL: When a customer asks about a specific brand, you MUST NOT use your training knowledge to decide whether the store carries that brand. ONLY the PRODUCT CATALOG is authoritative. If the catalog contains products with that brand name in their title — the store SELLS that brand. Present those products immediately. NEVER say 'we don't carry [Brand]' or 'we don't have products from this brand' when products with that brand name appear in the catalog.\n"; … … 610 615 611 616 $p .= "## PRODUCT CATALOG\n"; 612 $p .= "Fields: [ID:xxx] [PREV?] Name | Price | PriceRaw | Stock | Categories | URL | OnSale | RegularPrice | Delivery | Dims | Weight | ShortDesc | Attributes \n";613 $p .= "[PREV] = shown to this customer in an earlier message. Stock: INSTOCK / OUTOFSTOCK / BACKORDER / INSTOCK(N units) \n";617 $p .= "Fields: [ID:xxx] [PREV?] Name | Price | PriceRaw | Stock | Categories | URL | OnSale | RegularPrice | Delivery | Dims | Weight | ShortDesc | Attributes | ShipETA (optional)\n"; 618 $p .= "[PREV] = shown to this customer in an earlier message. Stock: INSTOCK / OUTOFSTOCK / BACKORDER / INSTOCK(N units). Delivery:PICKUP-ONLY = personal pickup only.\n"; 614 619 if ( $catalog_count > 0 && self::$is_approximate ) { 615 620 $p .= "STATUS: {$catalog_count} APPROXIMATE match(es). No exact match found — these are the CLOSEST products the search engine returned.\n"; … … 1450 1455 } 1451 1456 1457 /** 1458 * Filters one product line of the catalog sent to the AI 1459 * ("[ID:12] Name | price | … | field:value"). Append " | Field:value" 1460 * parts; a line break or a removed "[ID:n]" prefix drops the change. 1461 * 1462 * @since 1.5.3 1463 * 1464 * @param string $line Catalog line. 1465 * @param WC_Product $product Product. 1466 */ 1467 $filtered = apply_filters( 'sellai_catalog_product_line', $line, $product ); 1468 if ( is_string( $filtered ) && strpos( $filtered, "[ID:{$id}]" ) === 0 && strpbrk( $filtered, "\r\n" ) === false ) { 1469 $line = mb_substr( $filtered, 0, mb_strlen( $line ) + 500 ); 1470 } 1471 1452 1472 $lines[] = $line; 1453 1473 } … … 2186 2206 } 2187 2207 2188 return[2208 $card = [ 2189 2209 'id' => $product_id, 2190 2210 'name' => html_entity_decode( $product->get_name(), ENT_QUOTES | ENT_HTML5, 'UTF-8' ), … … 2200 2220 'sku' => $product->get_sku(), 2201 2221 ]; 2222 2223 /** 2224 * Filters the extra fields of a product card in the chat. Only 2225 * 'delivery' is read: a plain-text line shown under the stock label 2226 * (e.g. "Ships today if you order by 14:00"); '' shows none. The 2227 * other fields cannot be changed here. 2228 * 2229 * @since 1.5.3 2230 * 2231 * @param array $extra [ 'delivery' => '' ]. 2232 * @param WC_Product $product Product. 2233 * @param array $card Card data (read only). 2234 */ 2235 $extra = apply_filters( 'sellai_product_card_extra', [ 'delivery' => '' ], $product, $card ); 2236 if ( is_array( $extra ) && isset( $extra['delivery'] ) && is_scalar( $extra['delivery'] ) ) { 2237 $delivery = trim( (string) preg_replace( '/\s+/u', ' ', wp_strip_all_tags( (string) $extra['delivery'] ) ) ); 2238 if ( $delivery !== '' ) { 2239 $card['delivery'] = mb_substr( $delivery, 0, 160 ); 2240 } 2241 } 2242 return $card; 2202 2243 } 2203 2244 -
sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-prompt-presets.php
r3739994 r3792437 48 48 ], 49 49 'sales' => [ 50 'directive' => 'Be persuasive and conversion-focused. Every response MUST end with a clear call to action (e.g. "Click Add to cart to get yours today").',50 'directive' => 'Be persuasive and conversion-focused. Every response MUST end with a clear call to action (e.g. tell them to click the add-to-cart button to get theirs today).', 51 51 'force_cta' => true, 52 52 'prompt_cards' => 1, -
sell-ai-chatbot-for-woocommerce/trunk/includes/pro-bridge/class-sellai-hook-extension-points.php
r3790000 r3792437 62 62 * sellai_ab_testing_available ( bool $available = false ) Adds the sellai_ab cookie to the suggested privacy policy text (1.5.0, SellAI_Privacy). 63 63 * sellai_pre_chat_reply ( ?array $reply = null, string $message, array $context ) Answer a chat message before the FAQ and OpenAI: [ 'message', 'quick_replies'?, 'log_message'? ]; null continues as usual (1.5.2, SellAI_Ajax). 64 * sellai_catalog_product_line ( string $line, WC_Product $product ) One product line of the catalog sent to the AI; append " | Field:value" (1.5.3, SellAI_Product_Context). 65 * sellai_product_card_extra ( array $extra = [ 'delivery' => '' ], WC_Product $product, array $card ) Plain-text delivery line under the stock label of a chat product card (1.5.3, SellAI_Product_Context). 64 66 * 65 67 * ── Actions ───────────────────────────────────────────────────────── -
sell-ai-chatbot-for-woocommerce/trunk/public/css/chatbot.css
r3778395 r3792437 1382 1382 1383 1383 /* ── Stock status badges ── */ 1384 .sellai-pcard-delivery { 1385 display: block !important; 1386 margin-top: 3px !important; 1387 font-size: 11px !important; 1388 line-height: 1.35 !important; 1389 color: #475569 !important; 1390 } 1384 1391 .sellai-stock-ok { 1385 1392 display: inline-block !important; -
sell-ai-chatbot-for-woocommerce/trunk/public/js/chatbot.js
r3778395 r3792437 569 569 var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable')); 570 570 html += '<div class="' + (p.in_stock ? 'sellai-stock-ok' : 'sellai-stock-none') + '">' + esc(stockLabel) + '</div>'; 571 if (p.delivery) html += '<div class="sellai-pcard-delivery">' + esc(p.delivery) + '</div>'; 571 572 if (p.reason) html += '<div class="sellai-compare-reason">' + esc(p.reason) + '</div>'; 572 573 if (p.in_stock) { … … 627 628 var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable')); 628 629 html += '<div class="' + (p.in_stock ? 'sellai-stock-ok' : 'sellai-stock-none') + '">' + escName(stockLabel) + '</div>'; 630 if (p.delivery) html += '<div class="sellai-pcard-delivery">' + esc(p.delivery) + '</div>'; 629 631 630 632 if (p.reason) { … … 1356 1358 + '<span class="sellai-hist-icon">' + intent_icon + '</span>' 1357 1359 + '<span class="sellai-hist-ago">' + esc(conv.ago) + '</span>' 1358 + '<span class="sellai-hist-msgs">' + conv.message_count + ' msg</span>'1360 + '<span class="sellai-hist-msgs">' + esc(i18n('history_msgs').replace('%d', parseInt(conv.message_count, 10) || 0)) + '</span>' 1359 1361 + '</div>' 1360 1362 + '<div class="sellai-hist-summary">' + esc(conv.summary || i18n('history_no_summary')) + '</div>' -
sell-ai-chatbot-for-woocommerce/trunk/readme.txt
r3790000 r3792437 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.0 7 Stable tag: 1.5. 27 Stable tag: 1.5.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 202 202 203 203 == Changelog == 204 205 = 1.5.3 = 206 * Fix: the assistant could quote internal catalog codes such as "INSTOCK" to customers and guess dispatch or delivery times. It now describes availability in plain words and states delivery times only when the shop provides them. 207 * Fix: the assistant named the cart button "Add to cart" in English even in a Polish or German chat. It now uses the button label exactly as the widget shows it, also in the automatic "Ready to order?" call to action. 208 * Fix: in "Your previous conversations" the summaries are now written in the chat language (they were always in English), and "2d ago" / "3 msg" are translated. Summaries saved earlier stay as they are. 209 * Product cards in the chat can show a delivery line under the stock label (filled by add-ons such as Sell.AI Chatbot Pro with Sell.AI Stock, e.g. "Ships today if you order by 14:00"). Without an add-on nothing changes. 210 * For developers: new filters `sellai_catalog_product_line` (one product line of the catalog sent to the AI) and `sellai_product_card_extra` (delivery line of a product card). 204 211 205 212 = 1.5.2 = … … 302 309 == Upgrade Notice == 303 310 311 = 1.5.3 = 312 Adds the extension points that Sell.AI Pro 5.3 needs for delivery times in the chat. No changes for the free chatbot. 313 304 314 = 1.5.2 = 305 315 Adds the extension point that Sell.AI Pro 5.1 needs for order status in the chat. No changes for the free chatbot. -
sell-ai-chatbot-for-woocommerce/trunk/sell-ai.php
r3790000 r3792437 4 4 * Plugin URI: https://trysellai.com 5 5 * Description: AI-powered sales chatbot for WooCommerce. Helps customers find products, answers questions and boosts conversions. Powered by OpenAI GPT-5. 6 * Version: 1.5. 26 * Version: 1.5.3 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 8.0 … … 21 21 if ( ! defined( 'ABSPATH' ) ) exit; 22 22 23 define( 'SELLAI_VERSION', '1.5. 2' );23 define( 'SELLAI_VERSION', '1.5.3' ); 24 24 define( 'SELLAI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 25 25 define( 'SELLAI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Note:
See TracChangeset
for help on using the changeset viewer.