Reputation: 1
How can add url link for facebook messenger social share icon on product detail page?
Check for reference other social icons: https://magento.stackexchange.com/questions/226323/magento-2-social-share-buttons/226332
Upvotes: 0
Views: 386
Reputation: 233
Add this code in catalog_product_view.xml
<referenceContainer name="product.info.social">
<block class="Magento\Catalog\Block\Product\View" name="product.info.socialmedia" template="Magento_Catalog::product/view/socialmedia.phtml"/>
</referenceContainer>
And Create new phtml file at following path:
app/design/frontend/Custom/theme/Magento_Catalog/templates/product/view/socialmedia.phtml
Add below code in it.
<?php $_product = $block->getProduct(); ?>
<div class="social-media-icons">
<!-- Facebook -->
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($_product->getProductUrl());?>&t=<?php echo urlencode($_product->getName())?>" onclick='javascript:window.open(this.href,"","width=640,height=480,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes");return false' title="Share on facebook">
<img src=""<?php echo $this->getViewFileUrl('Magento_Catalog::images/facebook-share.jpg'); ?>" alt="Facebook" width="12%">
</a>
</div>
Upvotes: 0