Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
woocommerce adding js to product description

I have been asked to add a short JavaScript script to the short description of every product description on a WooCommerce site. It is actually an image with a simple "onclick" that scrolls smoothly to another part of the page, depending on different conditions. It has been added to every product via a PHP script directly to the MySQL DB. It works fine, but the only problem is that, when editing a product in the woo admin, the "onclick" part is automatically removed from the short description when saving the modifications, even when the short description hasn't been modified.

I am not familiar with WooCommerce nor with shortcodes nor with the best ways to use JavaScript in this environment.

So my question : is there a way to prevent the "onclick" part to be removed when saving changes, and if not, what is the best way to achieve the insertion of JavaScript inside a product short description, and keep it untouched when a product is edited ?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here is an example of how you can do this. You should add your script below code and add it in your theme functions.php. Your question is kinda unclear please share your code so we can understand your code and write the answer correctly.

function firefog_add_script_short_descr(){
  ?>
  <script>
    jQuery(document).ready(function($) {
     
     <!-- Your jquery code goes here-->
     
    })
  </script>
<?php  
}
add_filter('woocommerce_before_add_to_cart_form','firefog_add_script_short_descr');
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda