• 
    
    
    add_action( 'woocommerce_single_product_summary', 'whatsappdirect1', 35 );
     
    function whatsappdirect1() {
        echo '[anchor-tag a class="btn btn-social-icon btn-whatsapp" href="javascript:window.location=waCurrentPage();">[img tag border="0" alt="W3Schools" src="https://sareechoice.com/wp-content/uploads/2017/07/whatsappicon.png" width="290" height="200"][anchor-tag-closed]';
    }
    
    
    
    
    
    
    <script>
    waCurrentPage = function() {
      return encodeURI("whatsapp://send?phone=+9199999999&text=please let me know the price of the product in the link : " + 'https://' + window.location.hostname + window.location.pathname);
    }
    </script>
    
    

    hi,

    i have made the following codes that allows mobile users to contact my support team on my website on my whatsapp along with the link of the page ..so now in the above add_action code i have put the codes that will display my button which has to be clicked on the woocommerce product page …but now the problem is that the script codes which does actual work of opening my whatsapp number with predefault link that allow users to send it to my number …so how to insert that script code and also where to insert that ..is there anyway where i can keep both codes at one add_action function of wooocommerce …

    thanks in advance

    • This topic was modified 7 years, 4 months ago by moin12.
    • This topic was modified 7 years, 4 months ago by moin12.
  • The topic ‘want to add javascript in woocommerce add_action’ is closed to new replies.