Jump to content

Javascript code working from the console, but not from js.core file


Marcin Damian Lipski

Recommended Posts

Hello there

My name is Marcin and I am new to this forum. I have a javascript code that works perfectly from the console, but doesn't work when included in core.js  

var xxx = document.getElementsByClassName("checkout-step -reachable -complete -clickable"); for (var i = 0; i < xxx.length; i++) { let parass = document.createElement("p");

let nodess = document.createTextNode("completed"); parass.appendChild(nodess); let elementss = document.getElementsByClassName("checkout-step -reachable -complete -clickable")[i]; elementss.appendChild(parass);}

The code supposed to be triggered on the order (checkout) page, where visitors are filling their details in.

I would really appreciate any hints on how to troubleshoot this issue.

 

Best regards

Marcin

Link to comment
Share on other sites

On 12/8/2021 at 1:25 PM, Marcin Damian Lipski said:

but doesn't work when included in core.js  

You shoudn't modify core.js - you will loose everything with next Prestashop upgrade. Rather use custom.js file in your (child)-theme /assets/js folder

Link to comment
Share on other sites

On 12/13/2021 at 11:27 AM, Knowband Plugins said:

Kindly check whether the changes are reflecting on front or not, if reflecting and still not work, then please try to add your code in the below function (Kindly set delay as per your store requirement).

setTimeout(function() {

//your code to be executed after 1 second

}, 3000);

I rather recommend to load your code after page is ready:

$(document).ready(function () {
  
  // your code here

});

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...