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

139
Visualizações
Inserting HTML and PHP into a Javascript function

I'm currently working with a Wordpress plugin. I have amended one of the plugin files by adding some simple HTML code and a PHP variable associated with the plugin. Essentially duplicating a piece of code already in the file so I can repurpose the code using simple CSS.

(Essentially, the plugin dynamically displays the grand total of a product as different features are added. I just needed to duplicate this and display it as a fixed banner, so nothing in the plugin file I have added is new or changes the way the plugin functions.)

I'd like to be able to append this code using javascript so that when I update the plugin, my changes won't be lost.

This is what I have so far but I've had no success so far

function insertAfter(referenceNode, newNode) {
  referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}

var el = document.createElement("div");
el.innerHTML = "<div class="gt-banner-message">
    <div class="total-wrap">
            <span><?php _e('Grand total: ','advanced-product-fields-for-woocommerce'); ?></span>
            <span class="wapf-grand-total price amount"></span>
        </div>
    </div> ";
var div = document.getElementsByClassName("wapf-product-totals");
insertAfter(div, el);

Can someone let me know where I maybe going wrong here. Any advice much appreciated.

about 4 years ago · Juan Pablo Isaza
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