BigCommerce parameters

After you install the BigCommerce integration, the following parameter types are available. You can use these to incorporate content from BigCommerce into your components and compositions.

Parameter typeDescription
BigCommerce ProductSelect a single product from BigCommerce.
BigCommerce Product ListSelect multiple products from BigCommerce.
BigCommerce Product QuerySpecify search criteria that's used to select a single or multiple products from BigCommerce.

This parameter type allows a Uniform user to select a single BigCommerce product.

To allow a user to select a product from BigCommerce, you must add a parameter to a component. The parameter is used to store the identifier to the selected product when the user selects a product.

  1. In Uniform, navigate to your component.

  2. Add a new parameter using the parameter type BigCommerce Product.

  3. The following values can be specified:

    NameDescription
    RequiredIndicates whether the value is required when the component is used.
    parameter-config
    BigCommerce Product parameter configuration.

When you use a component with a BigCommerce Product parameter, by default no product will be selected. You are prompted to select a product.

  1. Click Select.

    edit-value-default
  2. Click the product you want to select.

    edit-value-filters

    About this step

    A couple of filters are available. The dropdown allows you to filter by content type. The text box allows you to filter by product name.

  3. Click Accept to save your selection.

    edit-value-selected
  4. You will see details about the product you selected, including the title and some metadata.

    edit-value-saved

    About this step

    After your selection is saved, you are presented with the following options:

    • If you want to edit the selected product in BigCommerce, click Edit.
    • If you want to deselect the product, click Unlink.

When a product is selected, Uniform only stores the identifier for the product. Your front-end application must retrieve the details for the product. Uniform provides an enhancer to simplify this process.

tip

Using the enhancer provided by Uniform saves you from having to write logic to interact directly with BigCommerce.

The following is an example of what Uniform stores for the parameter.

{ "type": "bigcommerceProduct", "value": "######################" }

The product ID is stored as the value.

Uniform provides an enhancer so you don't need to write the API calls to BigCommerce to retrieve data for products.

  1. Add the following npm packages to your front-end application:

    @uniformdev/canvas @uniformdev/canvas-bigcommerce
  2. In a text editor, open the file where you retrieve the composition definition from Uniform.

    About this step

    You are looking for the code calls the async function getComposition. The code below assumes the object returned is set in a variable composition.

  3. Add the following import statements:

    import { EnhancerBuilder, enhance } from '@uniformdev/canvas'; import { createBigCommerceEnhancer, createBigCommerceClient, CANVAS_BIGCOMMERCE_PARAMETER_TYPES, } from '@uniformdev/canvas-bigcommerce';
  4. Add the following code:

    const bigCommerceEnhancer = createBigCommerceEnhancer({ client: createBigCommerceClient({ storeHash: "!!! YOUR BIGCOMMERCE STORE HASH !!!", token: "!!! YOUR BIGCOMMERCE API TOKEN !!!", }), createProductOptions: () => { return { // Modify or exclude this property if you want // more fields returned from the BigCommerce API include_fields: ['id', 'name'], }; }, createProductQueryOptions: () => { return { // Modify or exclude this property if you want // more fields returned from the BigCommerce API include_fields: ['id', 'name'], }; }, });

    About this step

    We recommend you moving the BigCommerce credentials to environment variables rather than hard-coding them in the front-end app.

  5. Add the following code:

await enhance({ composition, enhancers: new EnhancerBuilder().parameterType( CANVAS_BIGCOMMERCE_PARAMETER_TYPES, bigCommerceEnhancer, ), context: {}, });

About this step

This registers the enhancer to be used for any occurrence of the BigCommerce Product parameter.

Next steps

Now the parameter value in the composition is mutated to include the field values for the selected BigCommerce product (instead of just being identifiers).

This parameter type allows a Uniform user to select multiple BigCommerce products.

To allow a user to select multiple products from BigCommerce, you must add a parameter to a component. The parameter is used to store the identifiers to the selected products when the user selects products.

  1. In Uniform, navigate to your component.

  2. Add a new parameter using the parameter type BigCommerce Product List.

  3. The following values can be specified:

    NameDescription
    RequiredIndicates whether the value is required when the component is used.
    add-parameter-to-component
    BigCommerce Product List parameter configuration.

This parameter type works the same way as BigCommerce Product, adding the ability to select multiple products from the list when the parameter value is edited.

edit-parameter-value
Example of the editing interface for a BigCommerce Product List parameter on a component.

This parameter type uses the same enhancer as the BigCommerce Product parameter type.

note

The parameter settings are stored in Canvas in a slightly different format. Instead of a single product ID being stored, the value is stored as an array of product IDs.

{ "type": "bigcommerceProductList", "value": [ "######################", "######################" ] }

This parameter type allows a Uniform user to configure a query that will determine the BigCommerce products that are retrieved.

In order to allow a user to configure a query to determine the products from BigCommerce to retrieve, you must add a parameter to a component. The parameter is used to store the query settings used to perform the search.

  1. In Uniform, navigate to your component.

  2. Add a new parameter using the parameter type BigCommerce Product Query.

  3. The following values can be specified:

    NameDescription
    RequiredIndicates whether the value is required when the component is used.
    add-parameter-to-component
    BigCommerce Product Query parameter configuration.

Configuring this parameter type involves specifying the way a product search should work. You are able to control the following search settings:

FieldDescription
BrandOnly products associated with the selected brand are included.
CountThe maximum number of products that are returned.
KeywordOnly products whose names match the specified keyword(s) are included.
SortThe product property used to sort the products that are returned.
Sort OrderWhether the products should be sorted in ascending or descending order.
edit-parameter-value
Example of the editing interface for a BigCommerce Product Query parameter on a component.

This parameter type uses the same enhancer as the BigCommerce Product parameter type.

note

The parameter settings are stored in Canvas in a slightly different format. Instead of a single product ID being stored, the value stores the settings used to perform the search.

{ "type": "bigcommerceProductQuery", "value": { "count": 1, "categories": [ "######################", "######################" ], "brand": "######################", "keyword": "######################", "sort": "######################", "sortOrder": "asc" } }