The WhatsApp configuration enables direct communication with customers via WhatsApp. This includes setting up your business phone number, customizing message templates, and providing utility functions for creating WhatsApp links.
import { createWhatsAppURL } from '@/config/whatsapp';// Using default message templateconst url1 = createWhatsAppURL('ABC Su 19L Damacana');// Returns: "https://wa.me/905303099887?text=Merhaba%2C%20ABC%20Su%2019L%20Damacana%20sipari%C5%9F%20etmek%20istiyorum."// Using custom messageconst url2 = createWhatsAppURL( 'ABC Su 19L Damacana', 'Bu ürünün fiyatı nedir ve ne zaman teslim alabilir miyim?');// Using product-specific template (if configured)const url3 = createWhatsAppURL('abc su');// Uses the custom message from productMessages["abc su"]
import { openWhatsApp } from '@/config/whatsapp';// Open WhatsApp chat with default messagefunction handleContactClick(productName) { openWhatsApp(productName);}// Open WhatsApp chat with custom messagefunction handleCustomInquiry(productName) { const message = `${productName} için toplu sipariş vermek istiyorum. Fiyat bilgisi alabilir miyim?`; openWhatsApp(productName, message);}
export const WHATSAPP_CONFIG = { phoneNumber: "905303099887", defaultMessage: "Hello, I would like to order {productName}.", productMessages: { // English messages "mineral water": "Hello! Could you provide details about this mineral water product?", // Turkish messages "maden suyu": "Merhaba! Bu maden suyu ürününüz hakkında detay alabilir miyim?" }};
For multi-language support, consider exporting message templates:
src/config/whatsapp.js
export const MESSAGES = { tr: { default: "Merhaba, {productName} sipariş etmek istiyorum.", outOfStock: "{productName} ne zaman stoğa girecek?", bulkOrder: "Toplu sipariş için fiyat bilgisi alabilir miyim?" }, en: { default: "Hello, I would like to order {productName}.", outOfStock: "When will {productName} be back in stock?", bulkOrder: "Can I get pricing for bulk orders?" }};export const getLocalizedMessage = (key, productName, locale = 'tr') => { const template = MESSAGES[locale]?.[key] || MESSAGES.tr[key]; return template.replace('{productName}', productName);};