• Resolved plamenyordanovdev

    (@plamenyordanovdev)


    Hi there,

    we have a very simple form of doing calculations based on colors and sizes.

    We sell products and we’ll be using your plugin for this.

    Some of our products have different sizes. Those sizes have X, Y, Z colors available.

    However, the bigger sizes have different colors available.

    How can we make a dependency so that when someone chooses a size A, he got to then choose only between certain colors?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @plamenyordanovdev

    You have multiple alternatives to display or populate the correct color list based on the size selected. The option to use depends on your copy of the plugin.

    Using the Free and Professional versions of the plugin:

    * First alternative: Insert multiple dropdowns or radio button fields with the list of colors, one per size. And define these new fields as dependent on the corresponding size choice in the dropdown or radio buttons for sizes. For example, assuming you have sizes: S, M, L, and XL, you might need four dropdown files for the colors. More information about dependencies by reading the following blog post:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies

    Handicap, you need multiple fields for colors.

    * Second alternative: Populate the colors list by programming. In this case, you need only one field for colors and a calculated field as an auxiliary to populate the colors choices. For example, assuming the size list is the fieldname123, and the colors list the fieldname321, the equation in the calculated field could be similar to:

    
    (function(){
        var texts = [], values = [];
        switch(fieldname123)
        {
            case 'S':
                texts = ['blue','red'];
                values = ['blue','red'];
            break;
            case 'M':
                texts = ['blue','red','white'];
                values = ['blue','red', 'white'];
            break;
            case 'L':
                texts = ['brown','yellow'];
                values = ['brown','yellow'];
            break;
            case 'XL':
                texts = ['black','red'];
                values = ['black','red'];
            break;
        }
        getField(321).setChoices({texts:texts, values:values});
    })()
    

    Handicap, you must edit the equation for every variation of size or color.

    Using the Developer and Platinum versions of the plugin:

    It is my preferred alternative because it allows me to update sizes and colors without touching the form.

    You can create a CSV file with pairs of size-color. Furthermore, to create, edit and maintain the CSV file, you can use Google Sheet. For example:

    size,color
    S,blue
    S,red
    M,blue
    M,red
    M,white
    L,brown
    L,yellow
    XL,black
    XL,red

    And then insert two DropDown DS fields in the form to get the sizes and colors from the CSV file.

    More information about the DS fields by reading the following blog post:

    https://cff.dwbooster.com/blog/2019/02/14/ds/

    Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Adding CUSTOM DEPENDENCIES’ is closed to new replies.