Plugin Directory

Changeset 3792437


Ignore:
Timestamp:
11/09/2026 12:23:46 PM (12 days ago)
Author:
creatywniwsiecipl
Message:

Release 1.5.3: delivery line on product cards, chat-language summaries, prompt fixes

Location:
sell-ai-chatbot-for-woocommerce
Files:
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-ajax.php

    r3790000 r3792437  
    17331733        // 3. CTA enforcement — buy intent but no add-to-cart/checkout phrase
    17341734        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' ) ) );
    17361737        }
    17371738
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-conversations.php

    r3739994 r3792437  
    263263        $transcript = mb_substr( $transcript, 0, 3000 );
    264264
    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 );
    272283
    273284        global $wpdb;
    … …  
    280291        );
    281292        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;
    282318    }
    283319
    … …  
    353389        foreach ( $rows as &$row ) {
    354390            $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'] );
    356393        }
    357394        return $rows;
    … …  
    376413    }
    377414
    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 {
    379420        $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 ) );
    385432    }
    386433
    … …  
    622669        foreach ( $history as $conv ) {
    623670            if ( ! $conv['summary'] ) continue;
    624             $lines[] = "- [{$conv['ago']}] {$conv['summary']}";
     671            $lines[] = "- [{$conv['ago_en']}] {$conv['summary']}";
    625672        }
    626673        if ( empty( $lines ) ) return '';
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-i18n.php

    r3739994 r3792437  
    6161            'history_title'        => '📋 Your previous conversations',
    6262            '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',
    6368            'history_load_btn'     => 'Load conversation →',
    6469            'history_loading'      => 'Loading...',
    6570            '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!',
    6772            'service_unavailable'  => 'The assistant is temporarily unavailable. Please try again later.',
    6873            'error_message_too_long' => 'Your message is too long. Please shorten it to 1000 characters.',
    … …  
    128133            'history_title'        => '📋 Twoje poprzednie rozmowy',
    129134            '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.',
    130140            'history_load_btn'     => 'Wczytaj rozmowę →',
    131141            'history_loading'      => 'Wczytywanie...',
    132142            '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”!',
    134144            'service_unavailable'  => 'Asystent jest chwilowo niedostępny. Spróbuj ponownie później.',
    135145            'error_message_too_long' => 'Wiadomość jest za długa. Skróć ją do 1000 znaków.',
    … …  
    195205            'history_title'        => '📋 Ihre früheren Gespräche',
    196206            '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.',
    197212            'history_load_btn'     => 'Gespräch laden →',
    198213            'history_loading'      => 'Laden...',
    199214            '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“!',
    201216            'service_unavailable'  => 'Der Assistent ist vorübergehend nicht verfügbar. Bitte versuchen Sie es später erneut.',
    202217            'error_message_too_long' => 'Ihre Nachricht ist zu lang. Bitte kürzen Sie sie auf 1000 Zeichen.',
    … …  
    262277            'history_title'        => '📋 Vos conversations précédentes',
    263278            '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',
    264284            'history_load_btn'     => 'Charger la conversation →',
    265285            'history_loading'      => 'Chargement...',
    266286            '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 » !',
    268288            'service_unavailable'  => 'L\'assistant est temporairement indisponible. Veuillez réessayer plus tard.',
    269289            'error_message_too_long' => 'Votre message est trop long. Veuillez le réduire à 1000 caractères.',
    … …  
    329349            'history_title'        => '📋 Tus conversaciones anteriores',
    330350            '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.',
    331356            'history_load_btn'     => 'Cargar conversación →',
    332357            'history_loading'      => 'Cargando...',
    333358            '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"!',
    335360            'service_unavailable'  => 'El asistente no está disponible temporalmente. Inténtalo de nuevo más tarde.',
    336361            'error_message_too_long' => 'Tu mensaje es demasiado largo. Acórtalo a 1000 caracteres.',
    … …  
    396421            'history_title'        => '📋 Le tue conversazioni precedenti',
    397422            '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',
    398428            'history_load_btn'     => 'Carica conversazione →',
    399429            'history_loading'      => 'Caricamento...',
    400430            '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"!',
    402432            'service_unavailable'  => 'L\'assistente non è temporaneamente disponibile. Riprova più tardi.',
    403433            'error_message_too_long' => 'Il messaggio è troppo lungo. Riducilo a 1000 caratteri.',
    … …  
    462492            'rate_limit_hour'      => 'Te veel berichten. Wacht even voordat u een nieuw bericht stuurt.',
    463493            '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"!',
    465495            'service_unavailable'  => 'De assistent is tijdelijk niet beschikbaar. Probeer het later opnieuw.',
    466496            'error_message_too_long' => 'Je bericht is te lang. Kort het in tot 1000 tekens.',
    … …  
    525555            'rate_limit_hour'      => 'Příliš mnoho zpráv. Počkejte chvíli před odesláním další.',
    526556            '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“!',
    528558            'service_unavailable'  => 'Asistent je dočasně nedostupný. Zkuste to prosím později.',
    529559            'error_message_too_long' => 'Zpráva je příliš dlouhá. Zkraťte ji na 1000 znaků.',
    … …  
    588618            'rate_limit_hour'      => 'Demasiadas mensagens. Por favor, aguarde um momento.',
    589619            '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"!',
    591621            'service_unavailable'  => 'O assistente está temporariamente indisponível. Tente novamente mais tarde.',
    592622            'error_message_too_long' => 'A sua mensagem é demasiado longa. Reduza-a para 1000 caracteres.',
    … …  
    651681            'rate_limit_hour'      => 'För många meddelanden. Vänta en stund innan du skickar igen.',
    652682            '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"!',
    654684            'service_unavailable'  => 'Assistenten är tillfälligt otillgänglig. Försök igen senare.',
    655685            '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  
    185185        $p .= "- Never hallucinate. Use ONLY data from the PRODUCT CATALOG.\n";
    186186        $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";
    188191
    189192        self::cut( $sections, 'sales_mission', $p );
    … …  
    205208        $p .= "Rule 1: Every product in the catalog EXISTS and is REAL. Never deny its existence.\n";
    206209        $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";
    207212        $p .= "Rule 3: Never invent products not in the catalog. Never claim a brand is absent if its products appear in the catalog.\n";
    208213        $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";
    … …  
    610615
    611616        $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";
    614619        if ( $catalog_count > 0 && self::$is_approximate ) {
    615620            $p .= "STATUS: {$catalog_count} APPROXIMATE match(es). No exact match found — these are the CLOSEST products the search engine returned.\n";
    … …  
    14501455            }
    14511456
     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
    14521472            $lines[] = $line;
    14531473        }
    … …  
    21862206        }
    21872207
    2188         return [
     2208        $card = [
    21892209            'id'            => $product_id,
    21902210            'name'          => html_entity_decode( $product->get_name(), ENT_QUOTES | ENT_HTML5, 'UTF-8' ),
    … …  
    22002220            'sku'           => $product->get_sku(),
    22012221        ];
     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;
    22022243    }
    22032244
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/class-sellai-prompt-presets.php

    r3739994 r3792437  
    4848            ],
    4949            '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).',
    5151                'force_cta'    => true,
    5252                'prompt_cards' => 1,
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/includes/pro-bridge/class-sellai-hook-extension-points.php

    r3790000 r3792437  
    6262                 * sellai_ab_testing_available ( bool $available = false )          Adds the sellai_ab cookie to the suggested privacy policy text (1.5.0, SellAI_Privacy).
    6363                 * 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).
    6466                 *
    6567                 * ── Actions ─────────────────────────────────────────────────────────
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/public/css/chatbot.css

    r3778395 r3792437  
    13821382
    13831383/* ── 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}
    13841391.sellai-stock-ok {
    13851392    display:       inline-block !important;
  • sell-ai-chatbot-for-woocommerce/tags/1.5.3/public/js/chatbot.js

    r3778395 r3792437  
    569569            var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable'));
    570570            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>';
    571572            if (p.reason) html += '<div class="sellai-compare-reason">' + esc(p.reason) + '</div>';
    572573            if (p.in_stock) {
    … …  
    627628            var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable'));
    628629            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>';
    629631
    630632            if (p.reason) {
    … …  
    13561358                  + '<span class="sellai-hist-icon">' + intent_icon + '</span>'
    13571359                  + '<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>'
    13591361                  + '</div>'
    13601362                  + '<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  
    55Tested up to: 7.1
    66Requires PHP: 8.0
    7 Stable tag: 1.5.2
     7Stable tag: 1.5.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    202202
    203203== 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).
    204211
    205212= 1.5.2 =
    … …  
    302309== Upgrade Notice ==
    303310
     311= 1.5.3 =
     312Adds the extension points that Sell.AI Pro 5.3 needs for delivery times in the chat. No changes for the free chatbot.
     313
    304314= 1.5.2 =
    305315Adds 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  
    44 * Plugin URI:        https://trysellai.com
    55 * 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.2
     6 * Version:           1.5.3
    77 * Requires at least: 6.0
    88 * Requires PHP:      8.0
    … …  
    2121if ( ! defined( 'ABSPATH' ) ) exit;
    2222
    23 define( 'SELLAI_VERSION',     '1.5.2' );
     23define( 'SELLAI_VERSION',     '1.5.3' );
    2424define( 'SELLAI_PLUGIN_DIR',  plugin_dir_path( __FILE__ ) );
    2525define( 'SELLAI_PLUGIN_URL',  plugin_dir_url( __FILE__ ) );
  • sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-ajax.php

    r3790000 r3792437  
    17331733        // 3. CTA enforcement — buy intent but no add-to-cart/checkout phrase
    17341734        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' ) ) );
    17361737        }
    17371738
  • sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-conversations.php

    r3739994 r3792437  
    263263        $transcript = mb_substr( $transcript, 0, 3000 );
    264264
    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 );
    272283
    273284        global $wpdb;
    … …  
    280291        );
    281292        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;
    282318    }
    283319
    … …  
    353389        foreach ( $rows as &$row ) {
    354390            $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'] );
    356393        }
    357394        return $rows;
    … …  
    376413    }
    377414
    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 {
    379420        $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 ) );
    385432    }
    386433
    … …  
    622669        foreach ( $history as $conv ) {
    623670            if ( ! $conv['summary'] ) continue;
    624             $lines[] = "- [{$conv['ago']}] {$conv['summary']}";
     671            $lines[] = "- [{$conv['ago_en']}] {$conv['summary']}";
    625672        }
    626673        if ( empty( $lines ) ) return '';
  • sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-i18n.php

    r3739994 r3792437  
    6161            'history_title'        => '📋 Your previous conversations',
    6262            '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',
    6368            'history_load_btn'     => 'Load conversation →',
    6469            'history_loading'      => 'Loading...',
    6570            '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!',
    6772            'service_unavailable'  => 'The assistant is temporarily unavailable. Please try again later.',
    6873            'error_message_too_long' => 'Your message is too long. Please shorten it to 1000 characters.',
    … …  
    128133            'history_title'        => '📋 Twoje poprzednie rozmowy',
    129134            '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.',
    130140            'history_load_btn'     => 'Wczytaj rozmowę →',
    131141            'history_loading'      => 'Wczytywanie...',
    132142            '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”!',
    134144            'service_unavailable'  => 'Asystent jest chwilowo niedostępny. Spróbuj ponownie później.',
    135145            'error_message_too_long' => 'Wiadomość jest za długa. Skróć ją do 1000 znaków.',
    … …  
    195205            'history_title'        => '📋 Ihre früheren Gespräche',
    196206            '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.',
    197212            'history_load_btn'     => 'Gespräch laden →',
    198213            'history_loading'      => 'Laden...',
    199214            '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“!',
    201216            'service_unavailable'  => 'Der Assistent ist vorübergehend nicht verfügbar. Bitte versuchen Sie es später erneut.',
    202217            'error_message_too_long' => 'Ihre Nachricht ist zu lang. Bitte kürzen Sie sie auf 1000 Zeichen.',
    … …  
    262277            'history_title'        => '📋 Vos conversations précédentes',
    263278            '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',
    264284            'history_load_btn'     => 'Charger la conversation →',
    265285            'history_loading'      => 'Chargement...',
    266286            '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 » !',
    268288            'service_unavailable'  => 'L\'assistant est temporairement indisponible. Veuillez réessayer plus tard.',
    269289            'error_message_too_long' => 'Votre message est trop long. Veuillez le réduire à 1000 caractères.',
    … …  
    329349            'history_title'        => '📋 Tus conversaciones anteriores',
    330350            '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.',
    331356            'history_load_btn'     => 'Cargar conversación →',
    332357            'history_loading'      => 'Cargando...',
    333358            '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"!',
    335360            'service_unavailable'  => 'El asistente no está disponible temporalmente. Inténtalo de nuevo más tarde.',
    336361            'error_message_too_long' => 'Tu mensaje es demasiado largo. Acórtalo a 1000 caracteres.',
    … …  
    396421            'history_title'        => '📋 Le tue conversazioni precedenti',
    397422            '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',
    398428            'history_load_btn'     => 'Carica conversazione →',
    399429            'history_loading'      => 'Caricamento...',
    400430            '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"!',
    402432            'service_unavailable'  => 'L\'assistente non è temporaneamente disponibile. Riprova più tardi.',
    403433            'error_message_too_long' => 'Il messaggio è troppo lungo. Riducilo a 1000 caratteri.',
    … …  
    462492            'rate_limit_hour'      => 'Te veel berichten. Wacht even voordat u een nieuw bericht stuurt.',
    463493            '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"!',
    465495            'service_unavailable'  => 'De assistent is tijdelijk niet beschikbaar. Probeer het later opnieuw.',
    466496            'error_message_too_long' => 'Je bericht is te lang. Kort het in tot 1000 tekens.',
    … …  
    525555            'rate_limit_hour'      => 'Příliš mnoho zpráv. Počkejte chvíli před odesláním další.',
    526556            '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“!',
    528558            'service_unavailable'  => 'Asistent je dočasně nedostupný. Zkuste to prosím později.',
    529559            'error_message_too_long' => 'Zpráva je příliš dlouhá. Zkraťte ji na 1000 znaků.',
    … …  
    588618            'rate_limit_hour'      => 'Demasiadas mensagens. Por favor, aguarde um momento.',
    589619            '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"!',
    591621            'service_unavailable'  => 'O assistente está temporariamente indisponível. Tente novamente mais tarde.',
    592622            'error_message_too_long' => 'A sua mensagem é demasiado longa. Reduza-a para 1000 caracteres.',
    … …  
    651681            'rate_limit_hour'      => 'För många meddelanden. Vänta en stund innan du skickar igen.',
    652682            '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"!',
    654684            'service_unavailable'  => 'Assistenten är tillfälligt otillgänglig. Försök igen senare.',
    655685            '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  
    185185        $p .= "- Never hallucinate. Use ONLY data from the PRODUCT CATALOG.\n";
    186186        $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";
    188191
    189192        self::cut( $sections, 'sales_mission', $p );
    … …  
    205208        $p .= "Rule 1: Every product in the catalog EXISTS and is REAL. Never deny its existence.\n";
    206209        $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";
    207212        $p .= "Rule 3: Never invent products not in the catalog. Never claim a brand is absent if its products appear in the catalog.\n";
    208213        $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";
    … …  
    610615
    611616        $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";
    614619        if ( $catalog_count > 0 && self::$is_approximate ) {
    615620            $p .= "STATUS: {$catalog_count} APPROXIMATE match(es). No exact match found — these are the CLOSEST products the search engine returned.\n";
    … …  
    14501455            }
    14511456
     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
    14521472            $lines[] = $line;
    14531473        }
    … …  
    21862206        }
    21872207
    2188         return [
     2208        $card = [
    21892209            'id'            => $product_id,
    21902210            'name'          => html_entity_decode( $product->get_name(), ENT_QUOTES | ENT_HTML5, 'UTF-8' ),
    … …  
    22002220            'sku'           => $product->get_sku(),
    22012221        ];
     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;
    22022243    }
    22032244
  • sell-ai-chatbot-for-woocommerce/trunk/includes/class-sellai-prompt-presets.php

    r3739994 r3792437  
    4848            ],
    4949            '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).',
    5151                'force_cta'    => true,
    5252                'prompt_cards' => 1,
  • sell-ai-chatbot-for-woocommerce/trunk/includes/pro-bridge/class-sellai-hook-extension-points.php

    r3790000 r3792437  
    6262                 * sellai_ab_testing_available ( bool $available = false )          Adds the sellai_ab cookie to the suggested privacy policy text (1.5.0, SellAI_Privacy).
    6363                 * 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).
    6466                 *
    6567                 * ── Actions ─────────────────────────────────────────────────────────
  • sell-ai-chatbot-for-woocommerce/trunk/public/css/chatbot.css

    r3778395 r3792437  
    13821382
    13831383/* ── 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}
    13841391.sellai-stock-ok {
    13851392    display:       inline-block !important;
  • sell-ai-chatbot-for-woocommerce/trunk/public/js/chatbot.js

    r3778395 r3792437  
    569569            var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable'));
    570570            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>';
    571572            if (p.reason) html += '<div class="sellai-compare-reason">' + esc(p.reason) + '</div>';
    572573            if (p.in_stock) {
    … …  
    627628            var stockLabel = p.stock_label || (p.in_stock ? i18n('in_stock') : i18n('unavailable'));
    628629            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>';
    629631
    630632            if (p.reason) {
    … …  
    13561358                  + '<span class="sellai-hist-icon">' + intent_icon + '</span>'
    13571359                  + '<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>'
    13591361                  + '</div>'
    13601362                  + '<div class="sellai-hist-summary">' + esc(conv.summary || i18n('history_no_summary')) + '</div>'
  • sell-ai-chatbot-for-woocommerce/trunk/readme.txt

    r3790000 r3792437  
    55Tested up to: 7.1
    66Requires PHP: 8.0
    7 Stable tag: 1.5.2
     7Stable tag: 1.5.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    202202
    203203== 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).
    204211
    205212= 1.5.2 =
    … …  
    302309== Upgrade Notice ==
    303310
     311= 1.5.3 =
     312Adds the extension points that Sell.AI Pro 5.3 needs for delivery times in the chat. No changes for the free chatbot.
     313
    304314= 1.5.2 =
    305315Adds 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  
    44 * Plugin URI:        https://trysellai.com
    55 * 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.2
     6 * Version:           1.5.3
    77 * Requires at least: 6.0
    88 * Requires PHP:      8.0
    … …  
    2121if ( ! defined( 'ABSPATH' ) ) exit;
    2222
    23 define( 'SELLAI_VERSION',     '1.5.2' );
     23define( 'SELLAI_VERSION',     '1.5.3' );
    2424define( 'SELLAI_PLUGIN_DIR',  plugin_dir_path( __FILE__ ) );
    2525define( 'SELLAI_PLUGIN_URL',  plugin_dir_url( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.