> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Display a product with a specific variant combination

> How to specify in WEBSALE V8s which dependent variant combination a product is called up with, either via product data or directly in the template.

When a customer opens a product with dependent variants, no combination is chosen initially. You can instead preselect a combination so the product immediately appears in a meaningful configuration. A shirt then shows, for example, sleeve length 65 cm and size 42 right away. The customer can still change the selection.

There are two ways to do this, differing in where the preselection is maintained.

| Way | Preselection is in | Useful when |
| - | - | - |
| Product data | one product data field per product | each product should get its own preselection |
| Template | the tag `PR-PreSelectDepVariation()` | the same rule should apply to all products of a template |

## Way 1: preselection in the product data

This preselection can be defined for simple products and for sets. Activation by WEBSALE is not required.

![Vorausgew Abh Var](https://mintcdn.com/websaleag-44ee7ea6/Gu3qq65BeVAUJPgW/images/vorausgew.abh.var.png?fit=max\&auto=format\&n=Gu3qq65BeVAUJPgW\&q=85\&s=455be63db953994231b18fcc63ebb2ef)

In the example above, after the corresponding definition, the selected shirt is shown by default with the preselected variants sleeve length = 65cm and size = 42.

### Set the product data field

For simple products, pass this field:

| Field name | Length | Description |
| - | - | - |
| `DefaultDepVarIndex` | maximum 64 characters | Variant index of the preselected dependent variant combination |

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<5-3406><12-3406>
```

For set products, a separate field is provided because several products are affected at the same time:

| Field name | Length | Description |
| - | - | - |
| `DefaultSetDepVarIndex` | maximum 1024 characters | List of variant indices for the set |

The list follows a fixed structure:

* as parameter-value pairs in URL format, without URL encoding
* the variant index of the set parent product in the parameter `depvar_index_setparent`
* the variant indices of the set sub-products in the parameters `depvar_index_set_<running index of the set sub-product>`

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
depvar_index_setparent=<PFLA644><PFLA644.135...1000>&depvar_index_set_1=<ZFLXXXXA><ZFLXXXXAA01>&depvar_index_set_2=<ZXXXX97N><ZXXXX97NN90>&depvar_index_set_3=<ZFLXXXXD><ZFLXXXXDD00>
```

The parameter list therefore has exactly the same format as the output of the tag `PR-SetLink`. If you are unsure how a list should look, display this output for the set and take it from there.

Reference: PR-SetLink&#x20;

> [!WARNING]
>
> If you specify a preselection for the entire set on a set product, the preselections of the individual set sub-products are no longer taken into account. This also applies when your specification only concerns parts of the set.

### Output the preselection in the template

Optionally, output the stored variant index on the product detail view, for example for verification.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{PR-DefaultDepVarIndex}
   ~PR-DefaultDepVarIndex~       <!-- Variant index of the product -->
{/PR-DefaultDepVarIndex}

{PR-DefaultSetDepVarIndex}
   ~PR-DefaultSetDepVarIndex~    <!-- List of variant indices of the set product -->
{/PR-DefaultSetDepVarIndex}
```

Reference: PR-DefaultDepVarIndex&#x20;

### Activate the feature

The maintained fields only take effect once you enable the feature in the shop configuration `shop.config` in the `<Basic>` section. The parameter knows two values, and the order is intentional: first check in test mode, then go live.

| Value | Effect |
| - | - |
| `test` | The preselection takes effect only in the shop's test mode |
| `yes` | The preselection takes effect in productive operation |

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<Basic>
...
UseDefaultDepVarIndex-Allow = test
...
</Basic>
```

With the value `test`, call the shop in test mode and check your products:

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
https://www.xyz.de/?test=on
```

If the preselected combinations appear as desired, end test mode and set the parameter to `yes`.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
https://www.xyz.de/?test=off
```

Reference: Basic section&#x20;

## Way 2: preselection in the template

Instead of per product, the preselection can also be set in the template. The tag `PR-PreSelectDepVariation()` expects two pieces of information: the desired combination and the behavior if this combination does not exist.

You specify the combination either via the variant name or via the variant index. For the case of unavailability, three behaviors are available: load the base product, load the closest combination, or load the first determined combination.

In the following example, the product is available in several colors and should appear with "sapphire blue". If this color is not available, the closest combination is loaded.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~PR-PreSelectDepVariation(nearestCombination,"Farbe=saphirblau")~
~PR-DepVariations~
```

Activation by WEBSALE is not required here either.

> [!NOTE]
>
> Only product fields and their values can be given in the preselection. Other information, for example stock, is not possible as a criterion.

If the preselection does not take effect as expected, a status code helps with troubleshooting. The meaning of the individual codes is given in the tag description.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Status code: ~PR-PreSelectDepVariationResultCode~
```

Reference: PR-PreSelectDepVariation()&#x20;

## Related topics

* Guide: Display dependent variants
* Guide: Set products
* Guide: Enable and disable the shop's test modes


## Related topics

- [Display dependent variants](https://dokumentation.websale.de/en/v8s/abhaengige-varianten/abhaengige-varianten-anzeigen.md)
- [Display dependent variants as a table](https://dokumentation.websale.de/en/v8s/abhaengige-varianten/abhaengige-varianten-als-tabelle-darstellen.md)
- [Variants](https://dokumentation.websale.de/en/admin-interface/katalog/produkte/varianten.md)
- [API reference products](https://dokumentation.websale.de/en/schnittstellen/admin-interface-api/api-referenz-produkte.md)
- [Product display](https://dokumentation.websale.de/en/ws-search/integration-in-die-templates-storefront/webcomponents/template-placeholder/produktanzeige.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.