How to add a Whatsapp link to a contact

Asked

Viewed 230 times

2

In my datatable there is a column called contacts, I want to add a link so that when the user clicks there, take the number for the variable and call with the Whatsapp link

<th><?= $properties['contato'] ?></th>

How could I do the same function in a modal

$('#view-property .modal-body').append(`<div><h4><b class="font-modal">Contato:</b> ${property.contato}</h4></div>`);

1 answer

5


The official Whatsapp API says to use:

https://api.whatsapp.com/send?phone=countrycode+phonenumber

soon to its context would be as follows:

<th><a href="https://api.whatsapp.com/send?phone=<?= $properties['contato'] ?>">Clique para ligar pelo Whatsapp</a></th>

remembering that its parameter $properties['contato'] should include the code of the country of origin of the number, in the case of Brazil is 55 an ex would be: 55DD9NUMERO

  • On that occasion, as I would put by default the +55 ?

  • if all the numbers are exclusively from the same country, you can put fixed, directly in the HTML construction as follows: <th><a href="https://api.whatsapp.com/send?phone=55<?= $properties['contact'] ? >">Click to call on Whatsapp</a></th>

  • I updated the question, on the first occasion even works, but on the second where my modal is not working.

  • In the context of modal you would have to have a link: $('#view-property .modal-body').append('<div><h4><a href="https://api.whatsapp.com/send?phone=${property.contato}"><b class="font-modal">Contato:</b> ${property.contato}</a></h4></div>');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.