Home New Guten › Forums › WoodMart support forum › Javascript not being triggered
Javascript not being triggered
- This topic has 7 replies, 2 voices, and was last updated 1 year, 9 months ago by
Artem Temos.
-
AuthorPosts
-
November 3, 2023 at 11:03 am #509572
maticParticipantHi,
I have activated a plugin for split payments (already tested it using another theme – it works) and I believe it does not work due to the optimization of the theme.
Marked part should display the “sliced” price.
the following script should run on the site however it does not:
<script>
const myJson =’ .getInstalmentJson(). ‘
const items = JSON.parse(myJson.installments);
const itemsArray = items.data.installmentInfoList;
function createOptions() {
var options = “”;
for (var i = 0; i < itemsArray.length; i++) {
var installmentNr = itemsArray[i].installmentNr;
if (installmentNr == 3 || installmentNr ==4){
options += “<option value=\'” + installmentNr + “\’>” + installmentNr + ” obroki</option>”;
}else{
options += “<option value=\'” + installmentNr + “\’>” + installmentNr + ” obrokov</option>”;
}
}
document.getElementById(“obroki”).innerHTML = options;
updateValue({value:itemsArray[0].installmentNr});
}
function updateValue(element) {
let calculation;
for (var i = 0; i < itemsArray.length; i++) {
if(itemsArray[i].installmentNr== element.value){
calculation = itemsArray[i].installmentValue;
}
}
calculation += ” €”;
calculation = calculation.replace(“.”, “,”);
document.getElementById(“term-amount”).innerHTML = calculation;
};
</script>
Please review, what could be done to resolve the problem, thank you
November 3, 2023 at 3:18 pm #509656
Artem TemosKeymasterHello,
Thank you so much for purchasing our theme and contacting our support center.
Could you please send us a screenshot of how it works with the default WordPress theme?
Kind Regards
XTemos StudioNovember 10, 2023 at 9:56 am #511324
maticParticipantHello, I just switched to the default theme and it works instantly, the dropdown shows and calculates the “sliced” price instantly.
Please check out what is wrong.
Best regards,
MaticAttachments:
You must be logged in to view attached files.November 10, 2023 at 10:16 am #511336
Artem TemosKeymasterHello,
Thank you. Please, disable all plugins that are not related to our theme and switch to the default theme so we can see how it should work and try to help you.
Kind Regards
November 10, 2023 at 1:31 pm #511441
maticParticipantI am sending you the link to the staging with everything turned off. Thank you
November 10, 2023 at 1:51 pm #511456
Artem TemosKeymasterTry to remove all the custom JS code from the custom JS section and place only this line to the Document on ready textarea
createOptions();
Kind Regards
November 10, 2023 at 2:19 pm #511471
maticParticipantAmazing, thank you so much!
November 10, 2023 at 3:07 pm #511484
Artem TemosKeymasterYou are welcome. Feel free to contact us if you have any further questions.
-
AuthorPosts
The topic ‘Javascript not being triggered’ is closed to new replies.
- You must be logged in to create new topics. Login / Register