Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!