It solved the problem for static Link
Now i am trying for Dynamic Link
But the input values are not getting Picked.
$w.onReady( function ()
{ $w(" #button44 “).link = “Share on WhatsApp” + $w(” #input1 “).value + “&text=How” + $w(” #input2 “).value;
$w(” #button44 ").target = “_blank”; }
);
I have also tried below code part earlier which use to work, but it now stopped working.
export function button44_click(event) {
$w(" #button44 “).link = “Share on WhatsApp” + $w(” #input1 “).value + “&text=How” + $w(” #input2 “).value;
$w(” #button44 ").target = “_blank”;
//Add your code for this event here: }
1 Like
I have already read the links mentioned.
It is a simple question how to direct a button on wix site to a dynamic link
where user can input fields which are are then part of the URL LINK
This not an integration problem.
Also, redirection does not work by setting the .link property in the click event handler. You should use wixLocation.to() for the redirect.
If you had read the links above you would have seen that from the WhatsApp own support document telling you how to implement it and that it needs to be changed to https://wa.me/… and not what you have with the https://api.whatsapp.com/…
https://faq.whatsapp.com/en/android/26000030/?category=5245251
Use: https://wa.me/15551234567
Don't use: https://wa.me/+001-(555)1234567
To create your own link with a pre-filled message that will automatically appear in the text field of a chat, use https://wa.me/whatsappphonenumber/?text=urlencodedtext where whatsappphonenumber is a full phone number in international format and URL-encodedtext is the URL-encoded pre-filled message.
Example:https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale
To create a link with just a pre-filled message, use https://wa.me/?text=urlencodedtext
Example:https://wa.me/?text=I'm%20inquiring%20about%20the%20apartment%20listing
After clicking on the link, you will be shown a list of contacts you can send your message to.
Plus, you would have also seen the link to Vorbly’s site where he gives you a fully working example of how to add it to your site along with images showing you how to have it setup on your page.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-WHATSAPP-CLICK-TO-CHAT
// Send Message //
export function Send_click(event) {
let phone = "11231231234"; // Your Phone Number: Country Code + Number //
let text1 = $w("#textBox1").value;
let text2 = text1.replace(/\s/g, "%20");
let link = "https://wa.me/" + phone + "?text=" + text2;
$w("#Send").link = link;
}
// Open Chat Box //
export function Chat_click(event) {
$w("#ChatBox").show();
$w("#Chat").hide();}
// Close Chat Box //
export function CloseChat_click(event) {
$w("#ChatBox").hide();
$w("#Chat").show();}
So in theory, all you need to do is to take Vorbly code example and add the setTimeout as Yisrael has stated in his link to give the code time to capture the full number and text message and you would be fine to go.
Finally, as you are trying to send a link out through WhatsApp, it is still technically a WhatsApp integration with Wix as you are using a link to an external WhatsApp on a persons device and something which is not anything to do with Wix itself.
Where do I insert this page code? I’m new to Corvid
Hi,
Is this post regarding if you want to contact a site member directly via whats app?
ill set the scene i have.
I run a meal plan company where by i create diets / meal plans for my clients and once a week they check in on my site.
here i can see various pieces of information they have filled in when submitting the check in, this is a custom form on wix and collated in a collection.
i can then as admin view the information via the dynamic page.
what i would like to do is have a button which opens whats app to the contacts whats app conversation and i can reply straight away to them.
now i saw the code written by wix here and tested it, this works fine and have a button for it however the phone number portion needs to be typed in manually and is where my question comes from.
question: how can i have the clients phone number dynamically changed to suit the dynamic client page i have open? on this page is it is easy for me to create a text box with the clients phone number in it from the clients sign up details stored in the private members data collection, bit how to get this into the code when you click the button to open whats app?
Many thanks
Dan
To link a button to your WhatsApp:
-
Add a button to your page.
-
Change the button text , for example, “Contact on WhatsApp”.
-
Click the Link icon .
-
Click Web Address .
-
Choose an option:
-
Create a link without a message: Add Share on WhatsApp where the is a full phone number in international format. Omit any zeros, brackets, or dashes when adding the phone number.
-
Create link with custom message: Add the link as above, and add text= with the message. For example, Share on WhatsApp . To add a space in custom message use ‘%20’. The default message in this example is “This is a test”.
- Click Done .
If i would be you and i never have done such a whattsApp-button before, my steps would be the following…
- Get some info for —> BUTTONS-API —> especially for Link-command.
https://www.wix.com/velo/reference/$w/button/link
Set an element to open an external web link:
$w("#myElement").link = "http://wix.com";
$w("#myElement").target = "_blank";
- Get some info for your dynamic-page and how to get data out of your DB using a dynamic dataset----> Dataset - Velo API Reference - Wix.com
especialy > getCurrentItem - Velo API Reference - Wix.com
Get the dataset’s current item when the page loads:
$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 let itemObj = $w("#myDataset").getCurrentItem();
4
5 } );
6
7} );
8
9/* itemObj:
10 *
11 * {
12 * "_id": "fcec780a-3e37-4b64-8a66-37c552c53f99",
13 * "_owner": "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
14 * "_createdDate": "2017-05-01T17:19:03.823Z",
15 * "_updatedDate": "2017-05-01T17:19:10.477Z",
16 * "title": "Dr. ",
17 * "name": "B",
18 * "link-dynamic-name": "/myCollection/B"
19 * }
20 */
- You will also have to create a good structured database with all needed values., where you will have all the information about your client/customer/site-member or what ever.
Your code could then look like something like this one:
$w.onReady(()=>{
let linkPrefix = "https://api.whatsapp.com/"
let actionPrefix = "send?phone="
let messagePrefix = "&text="
//let phoneNumber= "123456789" //--> deactivated fixed phone-Number as example
let text = "This%20is%20a%20test." //--> your message here
$w("#myDynamicDataset").onReady( () => {
let myCurrentItem = $w("#myDynamicDataset").getCurrentItem();
console.log(myCurrentItem)
let phoneNumber = myCurrentItem.xxx
//(xxx is the field where you will store the phone-number in your database)
// just take a look onto your CONSOLE to get more info about the structure of your own database
});
let PhoneNumPrefix = "<"+phoneNumber+">"
$w('#myButton').onClick(()=>{
$w("#myButton").link=linkPrefix+actionPrefix+PhoneNumPrefix+messagePrefix+text;
$w("#myButton").target = "_blank";
})
});
This is not a ready solution, but some theoretical thoughts, how i would try to solve your issue. The example is not tested, you will surely have to optimize/modify it.