• Resolved leggedy

    (@leggedy)


    Hi there,

    As we all know that the default link, if we click on our customer’s phone number would be;
    tel:{number}

    is there a way to customize it?

    Like I wanna change the link to be able to click and straight to WhatsApp.

    Now I am manually copying and pasting customer’s number into this;
    https://api.WhatsApp.com/send?phone=number

    pretty tedious.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    If you were referring to the linked Telephone number in the Order emails received by the administrator, it looks like you should be able to customize that by overriding the /woocommerce/templates/emails/email-addresses.php template file. We have info about overriding template files here:
    https://docs.woocommerce.com/document/template-structure/

    On the other hand, if you were referring to the phone number in the Edit order screen (after opening an order from WooCommerce > Orders), it doesn’t look like there is a simple PHP filter for customizing that. You could use some JavaScript to find the field and customize it. Or you could hook into the woocommerce_admin_order_data_after_billing_address action in woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php to add an extra field after the billing address fields with your custom WhatsApp link

    Thread Starter leggedy

    (@leggedy)

    Thanks for this @kellymetal

    Now the clickable link for woocommerce > order > edit order
    is good.

    but where do I look for, if I wanna change the clickable link for the preview box, refer to picture link for reference;
    https://ibb.co/X2rKN5V

    Thank you so much!

    I was looking all over google for a couple of months now

    Yes, Exactly i want same thing. instead of
    tel:xxxxxxxxxx

    need clickable link like
    https://api.whatsapp.com/send?phone=xx-xxxx-xxxx (Phone number)

    so i can chat through whatapp with my customeres.

    • This reply was modified 3 years, 8 months ago by chetan0412.
    • This reply was modified 3 years, 8 months ago by chetan0412.

    Hello @leggedy ,

    The preview pop-up content is coming up from this template –
    Path: \woocommerce\includes\admin\list-tables\class-wc-admin-list-table-orders.php
    Function: order_preview_template

    It does not have any hooks available to directly add custom data inside the main customer details list. You can hook the content to these hooks –

    do_action( 'woocommerce_admin_order_preview_start' );
    do_action( 'woocommerce_admin_order_preview_end' );

    You may need to get the order object separately for this. Here is a working example to add WhatsApp link both in the order edit page and preview page –

    add_action('woocommerce_admin_order_preview_start', 'add_whatsapp_link', 99);
    add_action('woocommerce_admin_order_data_after_billing_address', 'add_whatsapp_link');
    
    function add_whatsapp_link ($order) {
    
    	if(!$order) {
    		global $post;
    		$order = wc_get_order( $post->ID );
    	}
    
    	$phone_number =  $order->get_billing_phone();
    
    	?>
    		<p><strong>Whatsapp:</strong> 
    			<?php
    				printf("<a href='https://api.whatsapp.com/send?phone=%s'>%s</a>", $phone_number, $phone_number);
    			?>
    		</p>
    	<?php
    	
    }

    I hope this helps.

    Thank you ??

    Thread Starter leggedy

    (@leggedy)

    Yes, that works well! You save the day!
    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change clickable phone link tel:number to something else’ is closed to new replies.