Home New Guten Forums WoodMart support forum Javascript not being triggered

Javascript not being triggered

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #509572

    matic
    Participant

    Hi,

    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.

    https://ibb.co/K9M7Sk6

    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

    #509656

    Artem Temos
    Keymaster

    Hello,

    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 Studio

    #511324

    matic
    Participant

    Hello, 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,
    Matic

    Attachments:
    You must be logged in to view attached files.
    #511336

    Artem Temos
    Keymaster

    Hello,

    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

    #511441

    matic
    Participant

    I am sending you the link to the staging with everything turned off. Thank you

    #511456

    Artem Temos
    Keymaster

    Try 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

    #511471

    matic
    Participant

    Amazing, thank you so much!

    #511484

    Artem Temos
    Keymaster

    You are welcome. Feel free to contact us if you have any further questions.

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Javascript not being triggered’ is closed to new replies.