Way 1: preselection in the product data
This preselection can be defined for simple products and for sets. Activation by WEBSALE is not required.
Set the product data field
For simple products, pass this field:
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>
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
Output the preselection in the template
Optionally, output the stored variant index on the product detail view, for example for verification.Activate the feature
The maintained fields only take effect once you enable the feature in the shop configurationshop.config in the <Basic> section. The parameter knows two values, and the order is intentional: first check in test mode, then go live.
test, call the shop in test mode and check your products:
yes.
Way 2: preselection in the template
Instead of per product, the preselection can also be set in the template. The tagPR-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.
Only product fields and their values can be given in the preselection. Other information, for example stock, is not possible as a criterion.
Related topics
- Guide: Display dependent variants
- Guide: Set products
- Guide: Enable and disable the shop’s test modes
