feat: CTA dos cards e faixa de modalidades enviam ao WhatsApp com mensagem por pacote
Campo whatsapp_message editável por modalidade (Filament) com fallback para template padrão. Cards da home, faixa 'Conversar com a Amare' e CTA final da página de detalhe abrem o WhatsApp diretamente quando número configurado, mantendo briefing como fallback.
This commit is contained in:
@@ -67,6 +67,10 @@ class WeddingPackageForm
|
||||
->label('Texto do botão')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('whatsapp_message')
|
||||
->label('Mensagem do WhatsApp (deixe vazio para usar o padrão)')
|
||||
->helperText('Texto enviado ao cliente ao tocar no botão de contato. O nome da modalidade é citado automaticamente se vazio.')
|
||||
->rows(3),
|
||||
TextInput::make('compare_heading')
|
||||
->label('Comparação — título (leitura rápida)')
|
||||
->maxLength(255),
|
||||
|
||||
@@ -23,6 +23,7 @@ use Illuminate\Support\Str;
|
||||
* @property string $summary
|
||||
* @property list<string> $scope_items
|
||||
* @property string $cta_label
|
||||
* @property string|null $whatsapp_message
|
||||
* @property string|null $compare_heading
|
||||
* @property string|null $compare_summary
|
||||
* @property string|null $eyebrow
|
||||
@@ -54,6 +55,7 @@ use Illuminate\Support\Str;
|
||||
'summary',
|
||||
'scope_items',
|
||||
'cta_label',
|
||||
'whatsapp_message',
|
||||
'compare_heading',
|
||||
'compare_summary',
|
||||
'sort_order',
|
||||
|
||||
@@ -11,17 +11,47 @@ final class PackageContactLink
|
||||
/**
|
||||
* Resolve the contextual contact link for a wedding package modality.
|
||||
*
|
||||
* Uses the package-specific WhatsApp message when provided; otherwise
|
||||
* falls back to the default template with the modality name.
|
||||
*
|
||||
* @return array{href: string, isWhatsapp: bool}
|
||||
*/
|
||||
public static function for(SiteSetting $settings, string $packageName): array
|
||||
public static function for(SiteSetting $settings, string $packageName, ?string $customMessage = null): array
|
||||
{
|
||||
$message = filled($customMessage)
|
||||
? $customMessage
|
||||
: 'Olá, gostaria de conversar sobre a modalidade '.$packageName.' para meu casamento.';
|
||||
|
||||
return self::build($settings, $message, $packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a generic contact link (no specific modality), used by the
|
||||
* "Conversar com a Amare" guidance band.
|
||||
*
|
||||
* @return array{href: string, isWhatsapp: bool}
|
||||
*/
|
||||
public static function generic(SiteSetting $settings): array
|
||||
{
|
||||
return self::build(
|
||||
$settings,
|
||||
'Olá, ainda estou decidindo a modalidade ideal para o meu casamento. Podemos conversar?',
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{href: string, isWhatsapp: bool}
|
||||
*/
|
||||
private static function build(SiteSetting $settings, string $message, ?string $packageName): array
|
||||
{
|
||||
$digits = preg_replace('/\D/', '', (string) $settings->whatsapp_number);
|
||||
$isWhatsapp = strlen($digits) >= 10;
|
||||
|
||||
return [
|
||||
'href' => $isWhatsapp
|
||||
? 'https://wa.me/'.$digits.'?text='.rawurlencode('Olá, gostaria de conversar sobre a modalidade '.$packageName.' para meu casamento.')
|
||||
: route('briefing', ['servico_interesse' => $packageName]),
|
||||
? 'https://wa.me/'.$digits.'?text='.rawurlencode($message)
|
||||
: route('briefing', $packageName !== null ? ['servico_interesse' => $packageName] : []),
|
||||
'isWhatsapp' => $isWhatsapp,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user