Functions: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. This provides a useful starting point as you plan your implementation.

Add a fragile packaging fee from a function template (basic production flow)

Important:

For this flow, Wix Stores must be installed on the site.

To add a fragile packaging fee, use the Wix Stores Additional fees function type with the Fragile packing fee function template:

  1. To retrieve the additional fees function type, call Query Function Types.
    In the response, find the function type with the functionExtensionName set to Additional fees. Save this function type's ID.

  2. To retrieve the fragile packing fee function template, call Query Function Templates, filtering by the function type's ID retrieved in the previous step and the Wix Stores app ID, 215238eb-22a5-4c36-9e7b-e7c08025e04e.
    In the response, find the function template with the displayName set to Fragile packing fee. Save this function template's ID.

  3. To create the function, call Create Function Production, specifying the following parameters:

    • appId: The Wix Stores app ID, 215238eb-22a5-4c36-9e7b-e7c08025e04e.
    • type: TEMPLATE.
    • templateOptions.functionTemplateExtensionId: The fragile packing fee function template's ID, retrieved in the previous step.

    Note: This function type doesn't require a service plugin configuration.

    Save the IDs of the created function and automation provided in the response.

  4. To manage the function's logic, use the Automations API and the automation ID retrieved in the previous step.

  5. To activate the function, call Upsert Function Activation, specifying the function's ID.

Add a custom validation at checkout (basic production flow)

Important:

For this flow, Wix eCommerce must be installed on the site. Unlike other Wix apps, the eCommerce platform can't be installed by itself. Instead, the Wix eCommerce app is added automatically as a dependency when installing a business solution app that relies on its functionalities, such as Wix Stores.

To add a custom validation at checkout with custom logic, use the Wix eCommerce Checkout validations function type:

  1. To retrieve the checkout validations function type, call Query Function Types.
    In the response, find the function type with the functionExtensionName set to Checkout validations. Save this function type's ID and its service plugin configuration schema, functionType.function.configuration.servicePlugin.schema.

  2. To create the function, call Create Function Production, specifying the following parameters:

    • appId: The Wix eCommerce app ID, 1380b703-ce81-ff05-f115-39571d94dfcd.
    • type: BLANK.
    • functionSpiConfiguration: A custom configuration object that must adhere to the schema retrieved in the previous step. Note that this is an optional parameter and you can create the service plugin configuration later using the Function SPI Configuration API.
    • blankOptions.functionExtensionId: The function type's ID retrieved in the previous step.

    Save the IDs of the created function, automation, and function service plugin configuration provided in the response.

  3. To create and manage the function's logic, use the Automations API and the automation ID retrieved in the previous step.

  4. (Optional) To update the function's service plugin configuration, call Update Function Spi Configuration using the function service plugin configuration ID retrieved in the previous step.

  5. To activate the function, call Upsert Function Activation, specifying the function's ID.

Require a minimum number of different items at checkout (builderless production flow)

Important:

For this flow, Wix eCommerce must be installed on the site. Unlike other Wix apps, the eCommerce platform can't be installed by itself. Instead, the Wix eCommerce app is added automatically as a dependency when installing a business solution app that relies on its functionalities, such as Wix Stores.

To require a minimum number of different items at checkout using a builderless flow, use the Wix eCommerce Checkout validations function type with the Minimum number of different items function template:

  1. To retrieve the checkout validations function type, call Query Function Types.
    In the response, find the function type with the functionExtensionName set to Checkout validations. Save this function type's ID and its service plugin configuration schema, functionType.function.configuration.servicePlugin.schema.
  2. Call Query Function Templates, filtering by the function type's ID retrieved in the previous step and the Wix eCommerce app ID, 1380b703-ce81-ff05-f115-39571d94dfcd.
    In the response, find the function template with the displayName set to Minimum number of different items. Save this function template's formTemplateExtensionId.
  3. Call List Forms, specifying the following parameters:
    • namespace: wix.function_template.form
    • formIds: An array that contains the function template's formTemplateExtensionId retrieved in the previous step.
    • kind: EXTENSION
    Save the form fields provided in the response.
  4. To create the function, call Create Function Builderless Production, specifying the following parameters:
    • appId: The Wix eCommerce app ID, 1380b703-ce81-ff05-f115-39571d94dfcd.
    • formValues: An map of key
      pairs that contain the form fields retrieved in the previous step.
    • function.formTemplateExtensionId: The formTemplateExtensionId retrieved in an earlier step.
    • functionSpiConfiguration: A custom configuration object that must adhere to the schema retrieved in the previous step. Note that this is an optional parameter and you can create the service plugin configuration later using the Function SPI Configuration API. However, you must create the service plugin configuration before you can activate the function.
  5. To activate the function, call Upsert Function Activation, specifying the function's ID.

See also

Did this help?