Create a WhatsApp button with pre-filled text

Hi,

I want to add a WhatsApp button on the listing page.

When users click it, they go to WhatsApp with a pre-filled message like:

"Hello, I'm interested in this product: [listing title]
[listing URL]"

The WhatsApp number should come from the vendor profile attribute.

Currently, the button opens WhatsApp but the message field is empty.

Can you help me fix this?

My site: https://darkseagreen-pheasant-342833.hostingersite.com/

Thank you!

Hi @ahmad1,

Here’s HivePress AI’s reply:


Hello! I’d be happy to help you add a WhatsApp button with a pre-filled message on the listing page.

Based on your requirements, here’s what you need to do:

Step 1: Add a Phone Attribute to the Vendor Profile

  1. Go to Vendors > Attributes in your WordPress admin
  2. Click Add New
  3. Set the Type to Phone
  4. Make it Editable so vendors can add their WhatsApp number
  5. In the Format field, you’ll need a custom format (see below)

Step 2: Display Format with Pre-filled Message

For a WhatsApp button with a pre-filled message including the listing title and URL, the URL format needs to be:

https://wa.me/PHONENUMBER?text=YOUR_MESSAGE

However, implementing this with dynamic listing details (title and URL) requires custom development beyond the basic features. The standard format would be:

<a href="https://wa.me/%value%?text=Hello, I'm interested in this product" target="_blank" class="button button--large button--primary hp-button--wide">WhatsApp</a>

But this won’t dynamically include the listing title or URL.

Custom Implementation Required

To dynamically include the listing title and URL in the WhatsApp message, you’ll need custom code. This is beyond our standard support scope, but you have these options:

  1. Review code snippets: Check our collection at Search · user:hivepress · GitHub
  2. Hire an expert: Consider hiring a developer who can create this custom solution: Customize your website | HivePress

The customization would involve creating a custom shortcode that retrieves the vendor’s WhatsApp number and combines it with the listing details to generate the proper WhatsApp link.


Cheers,
Chris :victory_hand:

Hi,

I believe Chris has addressed your request. If you have any further questions, please let me know.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.