W
W
WebforSelf2019-02-01 21:18:03
JavaScript
WebforSelf, 2019-02-01 21:18:03

How to make a selection on Simpla CMS options from an array of additional parameters?

There are a lot of improvements (2 parameters for the variant or 3), but here it was necessary to make much more parameters for the variant.

What was done, a table was created to create additional options.
Accordingly, these additional options are selectively added when editing a product.
For example:
Create additional options:
Weight:
Height:
Length:
Width:
Next, go to the product card and link additional options to the product. All OK.
We fill in the options and additional options (parameters) and then the output of the additional ones themselves. options.

{foreach $product->dopvariant as $dv}
              <label>{$dv->name}</label>
             <select id="{$dv->id}" name="{$dv->id}">
      {foreach $product->variants as $v}
            <option value="{$v->id}">{$v->dopvariant.{$dv->id}}</option> 
            {/foreach}
      {/foreach}

We look at what additional options the product has and display its name.
Then, in the select, we display these parameters in a drop-down list.
All parameters are displayed, the question arose about sorting, i.e. I would like to sort so that the previous parameter sorts the next one.
Of course, we start with the standard option, for example, we have products

Option 1 Option 1 Option 1

20 kg 20 kg 25 kg
160 kg 160 kg 160 kg
200 cm 180 cm 180 cm
50 m 10 m 9 m

We select Option 1, the next select (the first parameter in the array) is sorted and since the values ​​are all Option 1, then the next select has 3 values, but 2 values ​​are the same, then there will be a choice of 20, 25 kg, We select 20 kg, and then a choice of 160 kg (the value is the same for everyone), but in fact we already choose from 2 products, the third is discarded.
Then choose 200 cm and 180 cm. We choose 200 and the parameter remains 50 m.
As a result, we chose 1 product.

Prompt how to implement exactly so that it does not depend on the number of parameters. Indeed, in one case there may be 4, in another 5, 6, etc.
js or ajax?
In fact, it goes like this, 5c548e45e5b1b640083519.pnga product variant is a standard, additional parameters are already a refinement.

The code above displays the name of the parameter first, and then an array of all parameters.
You need a sample as described above. Maybe someone just did something like this (not even on a simple)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question