Code samples
Getting started
This is an JS file (the configurator itself) and a basic stylesheet. The configurator depends on jQuery, so if you are not already using jQuery you should include it as well.
<div>
with an specific ID. This <div>
is then used to render the configurator in.For the examples below we expect a
<div id="configurationcontainer"></div>
somewhere on the page.Basic example
It is possible to use other data sources, but you should change the type and the options could also differ a bit, see Swagger for more details.
Initialize
Here you define which element (an
<div>
for example) will be used to place the configurator in.Furthermore you define the basic renderOptions (see below for more possibilities) and the type for these articles is always
logictrade
.
Starting the configuration
Here you provide the
articleCode
of the article that needs to be configured.
Finalizing the configuration / ordering
onComplete
event is called.In this event we call the
finish
function of the configuration service. This will return the configuration summary, which includes the final configurationHeaderId
.This configurationHeaderId can be used with the API to create a Sales order with this specific configuration.
Verifying configuration
In this way malicious edits of prices can be prevented.
1.
2.
verify
endpoint (configurator.logictrade.app/api/logictrade/verify).This POST request takes the full configuration object from the finish response as body. The response is a simple true
or false
.true
and the articleCode is the same, you are certain that the configuration has not been tampered with.In any other case, it is possible the configuration has expired, or the configuration has been tampered with.
Preview
Properties
init
function you have the following properties:element
the container were the configurator must be renderedtype
the type configuration (logictrade, curtain, a.s.o.)url
the URL of the configuration servicetoken
the token given by LogicTradeonChange
the function which will be executed when a change occurred, with the configuration as parameteronComplete
the function which will be executed when all required steps are answered, with the configuration as parameteronError
the function which will be executed when an error occurred, with the error as parameteronPriceChange
the function which will be executed when the price changed, with the price as parameteronImageChange
the function which will be executed when the article image is changed, with the image as parameter (object with 'rootImage' property)renderOptions
an object with some render optionsrenderLoader
when set to true, container will be rendered for a loaderautoScroll
when set to true, container will scroll to next configuration steplayout
the layout of the configuration, flex for div, table for tableccsPrefix
the prefix of the CSS classes of the rendered controlsrenderImages
show the images of the possible values in the rendered layoutuseSelect2
use the select2 library for rendering select controlrenderValueTemplate
the template to use for stylinginitialValuePlaceholder
When no answer is given, this placeholder text is shownrenderValueGroups
true/false. Turn grouping on or offvalueImagePlaceholder
URL or base64 encoded string. An image placeholder which will be shown when no answer image is availablerenderAdditionalInformation
show tooltip with additional information of the configuration steprenderPricePrefix
adds a + prefix to the shown price in the stepsstart
function in Swagger.Vue
In the example below, we give an example of using the configurator with Vue. This example assumes you are using Vuex.
In Vue, you can use the vue-plugin-load-script library for example to accomplish this. The example below uses this library.
configurator.cs
to load, initialize and interact with the configurator:
Modified at 2024-08-16 14:48:03