Magento2 Share product link for WhatsApp Web with bitly link

how to currentUrl share with bitly link?


$url = $objectManagerInstance -> get('Magento\Framework\UrlInterface');

$currentUrl = $url -> getCurrentUrl(); 

<div class="whatsapp_share <?php echo $size_class; ?>">
  <a href="whatsapp://send?text=<?php echo $text?>%0A%0A<?php echo "",$currentUrl."";?>"><?php echo __('Share');?></a>

Please try with below link for share products in whatsapp ( for bitly link - can you share url format ? ) .


I hope its work for you.


I guess, that you want to generate a product link, using the bit.ly API, that can easily be shared using WhatsApp?

And you should be done.


you can do it this way...

<?php $urlInterface = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\UrlInterface');
    $_currentUrl = $urlInterface->getCurrentUrl();
<a href="whatsapp://send?text=<?php echo $_currentUrl?>" data-action="share/whatsapp/share"><img src='WHATSAPP_ICON_IMG_SRC_HERE' /></a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.