Eğer woocommerce altyapısı kullanıyorsanız
functions.php en sonuna ekleyin
function replace_add_to_cart_with_whatsapp_link() {
if (is_product()) {
$whatsapp_link = 'https://api.whatsapp.com/send?phone=55555555555555';
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action('woocommerce_single_product_summary', function() use ($whatsapp_link) {
echo '<a href="' . esc_url($whatsapp_link) . '" class="button">WhatsApp ile İletişime Geçin</a>';
}, 30);
}
}
add_action('wp', 'replace_add_to_cart_with_whatsapp_link');temanın kendi stillerini alıp ekleyecektir.
function replace_add_to_cart_with_whatsapp_link() {
if (is_product()) {
$whatsapp_link = 'https://api.whatsapp.com/send?phone=55555555555555';
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action('woocommerce_single_product_summary', function() use ($whatsapp_link) {
echo '<a href="' . esc_url($whatsapp_link) . '" class="whatsapp-button">WhatsApp ile İletişime Geçin</a>';
}, 30);
}
}
add_action('wp', 'replace_add_to_cart_with_whatsapp_link');
add_action('wp_head', 'custom_whatsapp_button_css');
function custom_whatsapp_button_css() {
if (is_product()) {
?>
<style type="text/css">
.whatsapp-button {
display: inline-block;
background-color: #25d366;
color: #fff;
padding: 10px 15px;
text-decoration: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.whatsapp-button:hover {
background-color: #128C7E;
}
</style>
<?php
}
}
Bu kod sepete ekle butonunun silip yerine whatsapp iletişime geçin ekleyecektir. İsmi sepete ekle olarak değiştirebilirsiniz