Customizing product option forms

In case you have special requirements for product options of your products, such as:

  • more text fields for a product option, or
  • a second field that displays only when a specific option was selected in the first one,

it is possible to customize the product option form to achieve your needs. First, you need to add a field to the product option form. Then, second, you must enable it on the alternative form of the SKU. If you want one of the fields to be somehow dependent on each other, you can set dependencies after that.

Before you start to customize product option form, try to use product variants.

Adding a field to the product option form

  1. Open the Modules application.
  2. Edit () the E-commerce module.
  3. Switch to the Classes tab.
  4. Edit () the SKU class.
  5. Switch to the Fields tab.
  6. Create a new field according to your needs.
    • Leave Standard field in Field type.
    • Clear the Display field in the editing form field.
  7. Click Save.
    Finished custom field

The system adds the field to the SKU form and also creates a record of the field in your database.

On this page

Enabling the field in an alternative form

  1. Open the Modules application.
  2. Edit () the E-commerce module.
  3. Switch to the Classes tab.
  4. Edit () the SKU class.
  5. Switch to the Alternative forms tab.
  6. Edit () one of the Option forms to which you want to add the custom field.
  7. Switch to the Fields tab.
  8. Select the custom field in the left list.
  9. Select Display field in the editing form.
  10. Set the form appearance according to your needs.
  11. Click Save.
    Enabled custom field

The system starts to display the custom field on the Options tab in details of every option of the chosen product option category type.

Setting visibility dependency on two fields

If you want one field to be visible only when there is a specific value in another field, you must set it while editing the fields. See the following example.

We sell T-shirts and every T-shirt has a printed label. There are two types of labels – predefined ones and custom ones. Every T-shirt has a dropdown list in which there are a list of predefined labels and "Custom label". If a user selects "Custom label", a textbox displays, to which the user writes their custom label.

Since there are two types, we want to edit the attribute option form, where we create two new fields, one for predefined labels and one for custom labels.

Creating the fields

  1. Open the Modules application.
  2. Edit () the E-commerce module.
  3. Switch to the Classes tab.
  4. Edit () the SKU class.
  5. Switch to the Fields tab.
  6. Create a field for predefined labels:
    1. Click New field.
    2. Enter attributes of the field:
      • Field name: PredefinedLabels
      • Display field in the editing form: No (cleared)
    3. Click Save.
      Attributes of the field Predefined labels
  7. Create a field for custom labels:
    1. Click New field.
    2. Enter attributes of the field:
      • Field name: CustomLabels
      • Display field in the editing form: No (cleared)
    3. Click Save.
      Attributes of the field Custom labels

The system has a database records for the fields but they are not displayed anywhere.

Setting dependencies

  1. Switch to the Alternative forms tab.
  2. Edit () the Option (Attribute) form.
  3. Switch to the Classes tab.
  4. Edit () the SKU class.
  5. Switch to the Fields tab.
  6. Select PredefinedLabels from the left list.
  7. Edit attributes of PredefinedLabels:
    • Required: Yes (selected)
    • Display field in the editing form: Yes (selected)
    • Field caption: T-shirt label
    • Form control: Drop-down list
    • Data source: List of options
    • To the Data source textbox, enter these values:

      1;T-shirt with label
      2;Label on T-shirt
      3;Printed label
      4;Custom label
    • Has depending fields: Yes (selected)
  8. Click Save.
  9. Select CustomLabels from the left list.
  10. Edit attributes of CustomLabels:
    • Display field in the editing form: Yes (selected)
    • Field caption: Write your custom label
    • Visibility condition: PredefinedLabels == 4

      The number is 4 because it's the number of "Custom label" in the Data source textbox.

    • (Optional) Enabled condition: PredefinedLabels == 4

    • Depends on another field: Yes (selected)
  11. Click Save.
  12. Using Move up () and Move down (), position both fields closely under SKUEnabled.
    • This ensures that the fields are visible.

The fields are displayed on the product options page. The PredefinedLabels field is displayed always. When a user selects Custom label in PredefinedLabels, the CustomLabel appears.

You can check the result if you navigate to the Product options application and edit some product option from an attribute product option category, where you can see the fields.