Okay
  Public Ticket #1635220
Settings for slider
Closed

Comments

  • Terje Lien started the conversation

    Hi!

    I want settings on slider so that the increase is the same all the time, after a given value.
    For example, if the square meter is 20 and the value of this is 400. Then I want an increase of 30 per 5 square meters. 25 sqm = 430, 30 sqm = 460 35 sqm = 490 and so on. 

    Want I want is a fixed increase after a given value (after 20 in this example).

    I only want to use slider, and I assume I have to use Cost Calculator Grup, if/else conditions. I do not want to use switch or Select, only Slider

    How to do this?

  •  607
    Support Agent replied

    Hi Terje,

    Yes, for this, you will need Cost Calculator Group element. Once you add group, and drag slider to it, the pseudo code would look something like this:

    slider = $1;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 400;
    if (slider == 25) final = 430;
    if (slider == 30) final = 460;
    return final;

    Please note that the code is just an example and you need to further customize it according to your needs.

    Let us know if you need additional help.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    Thank’s!

    What references in slider to connect with pseudo code?

    Regards 

    Terje

  •  607
    Support Agent replied

    Hi Terje,

    It is the first line(s) in pseudo code that reference the elements in the group. They assign the current values of contained calculator items to your variables. You need to have one line for EACH calculator item within the calculator group.

    So, for example, if you only have slider, the variable would look like this:

    slider = $1;

    And then the rest of the code goes bellow.

    Please note that you can name variable any way you want. It's only important, if you have more than one, to list them in the same way they are listed in the group.

    You can find additional info in our online documentation.

    Let us know if you need additional help.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    But where in the slider calc shall I place slider = $1;? When placed just in Cost Calculator Group this not working.

    Another thing: Values which increase with 5 (20, 25 and so on), does that in slider up 1000+. I Can not have a variable for each of them. How to simplify code with increments, or other code?

  •  607
    Support Agent replied

    Hi Terj,

    You don't need to add anything to slider element, except for necessary values - min and max, step, unit.

    If the group is not working, it is possible that something isn't set correctly. Like we noted, you might need to customize the code additionally.

    If we understood well, the slider goes up to 1000 in value. It is possible to have simplified code, but it might be a bit difficult to define one line of code for all those values and have them calculated properly.

    You would need to set the Unit value of slider to 30, and then have the code for example:

    slider = $1;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 400;
    if (slider > 20) final = 400 + slider;
    return final;
    

    Again, this is just an example, and you need to adjust it according to your needs.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    Thank's for support!

    In addition, I want a Select function whose user can select a value from 1-3 that multiplies the total sum from slider (see slider code below) ( Value 1*value from slider 1, value 2*value from slider 1 and so on). 

    Slider code:

    slider = $1;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 500;
    if (slider > 20) final = 400 + slider;
    return final;

    See link to page: https://renluksus.no/regelmessig-renhold/

    How to do this?

    Thank you in advance!

  •  607
    Support Agent replied

    Hi Terje,

    In order to have select element included in calculation, you should also add it to the group and define in pseudo code.

    For example:

    slider = $1;
    select = $2;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 500 * select;
    if (slider > 20) final = (400 + slider) * select;
    return final;
    

    Let us know if this helped.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    Great, thank’s!

    Now I need a switch wich Can give a discount (per cent) on values from slider and select. How to do that?

  •  607
    Support Agent replied

    Hi Terje,

    In that case, the switch should also be added to the group in the same manner.

    The discount would be calculated like this:

    if (slider > 20) final = ((400 + slider) * select) - ((400 + slider) * select) * 0.20);
    

    The example is with 20% discount.

    Please adjust the code according to your needs.

    Let us know if you need additional help.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    I do not Get this code to work. Comes what you suggested in addtion to the rest of the code? 

    Existing code in Cost Calculator Group is this:

    slider = $1;
    select = $2;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 500 * select;
    if (slider > 20) final = ((400 + slider) * select);

    return final;

    If I replace some of the code you gave me, IT won’t work.

    What about the switch? What values shall I have there?

  •  607
    Support Agent replied

    Hi Terje,

    Like we noted, switch needs to also be added to the Cost Calculator group and defined in pseudo code.

    For example:

    slider = $1;
    select = $2;
    switch = $3;
    if (slider == 0) final = 0;
    if (slider <= 20) final = 500 * select;
    if (slider > 20) final = ((400 + slider) * select) - switch;
    return final;
    

    Let us know if you need additional help.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Terje Lien replied

    Ok, thank’s!

    But in switch operator you Can not set an per cent value? I would like to have switch which gave an discount in per cent when activated. How?

  • Terje Lien replied

    I have tried the code that includes switch operator and it will not work. Total sum is blank when using this code. Why?

    Is there another way I can visualize a discount in percentage than using a switch?

  •  607
    Support Agent replied

    Hi Terje,

    In that case, you can set the switch to have, for example, off value 0 and on value 1, and then define what percentage of discount will be added to the total.

    For example:

    slider = $1;
    select = $2;
    switch = $3;
    if (slider == 0) final = 0;
    if ((slider <= 20) && (switch == 1)) final = (500 * select) - ((500 * select) * 0.2);
    if ((slider > 20) && (switch == 1)) final = ((400 + slider) * select) - (((400 + slider) * select)) * 0.2);
    return final;
    

    Again, this is an example of 20 percent discount. Please further adjust the code according to your needs.

    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!