From 7a56ec25a04097c85dde2aa12efcce427c6e6fdc Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 3 Jul 2026 10:32:15 -0500 Subject: [PATCH] fix(wa): usar language_code real de la plantilla (es, no es_CO) Co-Authored-By: Claude Sonnet 4.6 --- debug_turno_wa.php | 5 +++-- modules/turnero/api/create_turno.php | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/debug_turno_wa.php b/debug_turno_wa.php index 43af832..4ca04bd 100644 --- a/debug_turno_wa.php +++ b/debug_turno_wa.php @@ -175,8 +175,9 @@ if (isset($_GET['test_cel'])) { echo "5. TEST DE ENVÍO\n"; echo "─────────────────\n"; $testCel = trim($_GET['test_cel']); - $testTpl = $cfg['turnero_wa_template'] ?? 'consentimiento_turno'; - $testLang = $cfg['turnero_wa_lang'] ?? 'es_CO'; + $testTpl = $cfg['turnero_wa_template'] ?? 'consentimiento_turno'; + // Usar el idioma real de la plantilla aprobada en Meta + $testLang = $tplRow['language_code'] ?? ($cfg['turnero_wa_lang'] ?? 'es'); require_once __DIR__ . '/services/WhatsAppService.php'; $baseUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; diff --git a/modules/turnero/api/create_turno.php b/modules/turnero/api/create_turno.php index 55bb25a..30f505a 100644 --- a/modules/turnero/api/create_turno.php +++ b/modules/turnero/api/create_turno.php @@ -153,11 +153,14 @@ try { $waTemplate = $esSoloMuestra ? ($cfgWA['turnero_wa_template_muestra'] ?? 'turno_muestra_pendiente') : ($cfgWA['turnero_wa_template'] ?? 'consentimiento_turno'); - $waLang = $cfgWA['turnero_wa_lang'] ?? 'es_CO'; + // Usar idioma real de la plantilla aprobada (puede diferir del config) + $stmtLang = $pdo->prepare("SELECT language_code FROM message_templates WHERE template_name = ? LIMIT 1"); + $stmtLang->execute([$waTemplate]); + $waLang = $stmtLang->fetchColumn() ?: ($cfgWA['turnero_wa_lang'] ?? 'es'); } catch (\Throwable $e) { $waKioskoEnabled = true; $waTemplate = 'consentimiento_turno'; - $waLang = 'es_CO'; + $waLang = 'es'; } }