Button for make a telephone call in mobile version taking the number from data base

Good day, I thank you in advance for the support that you have given to development from WIX, I have learned many things without being a programmer, today I wanted to ask for help.

I have a WIX project and I needed to make a button take a number from the database phone and make the call on a dynamic page of items, this means that every time you enter a different dynamic page, the button loads that diferent phone number depending on the entry for that item and when clicking open on the phone the Call application.

Again I appreciate all the support as I said I am not a programmer so if possible could you share the code to adapt it to the page?

THANK YOU!

If you want to look at making phone calls, then look at using the Wix Location API and the to function.
https://www.wix.com/corvid/reference/wix-location.html#to

Make a phone call

import wixLocation from 'wix-location';

// rest of code... //

wixLocation.to("tel:+1-555-555-5555");
1 Like

Or just do it through the Wix Editor itself.
https://support.wix.com/en/article/creating-a-clickable-phone-number
https://support.wix.com/en/article/guidelines-for-creating-a-clickable-phone-number-email-or-url

Or third party app.
https://support.wix.com/en/article/third-party-app-free-call

As for dynamic calls, see this previous forum post for more info.
https://www.wix.com/corvid/forum/community-discussion/dynamic-phone-number-changes-insertion-tracking

1 Like

Thank you very much I was able to achieve it, I thought about sharing a post with my solution but apparently it is not allowed to publish in the forum to anyone.

1 Like

Dynamic button for phone calls and whats app on item dynamic page (dinamic number from database)

My solution: On the dynamic page of item we create a text field to which we are going to name “phoneButton” and connect it to the database to the “telephone” field.

Then we create the button that sends the call and name it “phoneButton” which we will activate in properties on click and name the event as “phoneButton_click”

Then write the following code.


import wixLocation from 'wix-location';
export function phoneButton_click (event) {
wixLocation.to("tel:" + $w ("#telephone").value);
}

If you want the button to open whats app and also have a personalized message you must use this code and replace what you need rename the button "whatsButton and replace de **** for country code.


export function whatsButton_click (event) {
wixLocation.to("https://wa.me/****" + $w ("#telephone").value + "?text=hi,%20this%20is%20an%20example");
}

I clarify that I am not a programmer nor do I speak English, I have learned a lot in this space and I hope to contribute as a way to thank.

1 Like

Thanks for posting your working code, it will help others if they use the search function within the forum to look for similar issues.

2 Likes

What you have done below is fine as you keep it all together :+1:

@givemeawhisky this code is not working

I have a same situation i want to add onclick button call at dynamic page which will be profile for different users . In which users will share there information phone numbers as well to other who want it so they just have to tap on button and it will take it to directly on call . Could you please help me out with this .#gos