If you go through the “Elements” module, you won’t have to worry about this guide, on the other hand if you go through the API to add an element and you want to add variations to this element, you will have to make sure to pass an array containing the variations.

Here is an example of adding element with variations using API :

var instance = new AsukaDesigner('#myId'); // Create an instance of the main plugin class

instance.designer().addElement('Tshirt', null /* or category name */, null /* or icon URL */, [
    {
        name: 'First variation',  
        color: '#ffffff',
        image: {
            url: 'http://image-url',
            name: 'image name',
        },
        active: true,
    },
    {
        name: 'Second variation',  
        color: '#000000',
        image: {
            url: 'http://image-url',
            name: 'image name',
        }
    }
]) // Access the designer class and all his methods

Here is an example of adding element with derivatives using API :

var instance = new AsukaDesigner('#myId'); // Create an instance of the main plugin class

instance.designer().addElement('Watch', null /* or category name */, null /* or icon URL */, [
    {
        name: 'First derivative', 
        variations: [
			{
				name: 'First variation',  
				color: '#ffffff',
				image: {
					url: 'http://image-url',
					name: 'image name',
				},
				active: true,
			},
			{
				name: 'Second variation',  
				color: '#000000',
				image: {
					url: 'http://image-url',
					name: 'image name',
				}
			}
        ],
        active: true
    },
    {
        name: 'Second derivative',  
        variations: [
			{
				name: 'First variation',  
				color: '#ffffff',
				image: {
					url: 'http://image-url',
					name: 'image name',
				},
				active: true,
			},
			{
				name: 'Second variation',  
				color: '#000000',
				image: {
					url: 'http://image-url',
					name: 'image name',
				}
			}
        ]
    }
]) // Access the designer class and all his methods

Was this article helpful to you? Yes No

How can we help?