Plugins
In the Commerce system, plugins are used to load additional data on the product listing page. Currently, there is only one type of plugin available. New plugin definitions are requested and developed by the Commerce team based on requirements.
Available Plugin:
products.listable_product_variants
The only plugin currently available in the system allows additional data, defined for the plugin, to be added to the existing product data on the listing page. Once a plugin is defined, existing products must be reindexed to reflect its effects.
The next section details how to list and create plugins using the Commerce API.
Listable Product Variants Plugin
The products.listable_product_variants
plugin is used to add extra data to the extra_data
field within a product on the listing page.
Default extra_data
Field Without Plugin:
extra_data
Field Without Plugin:If the plugin is not available or is inactive, the extra_data
field of a product on the listing page appears as follows:
Modified extra_data
Field with Plugin:
extra_data
Field with Plugin:When the plugin is configured with the following settings:
The extra_data
field on the listing page is modified as follows:
The modified structure results from defining attribute_keys
with values like color
and size
. This allows variants of the product based on these attribute values to be listed within extra_data
.
Additionally, the product_field_names
setting defines which fields of the variant products should be included in the response. In the example above, the fields pk
, price
, absolute_url
, productimage_set
, and attributes
are specified, ensuring that these details are included when displaying variant products.
The attributes specified in attribute_keys
must be variant attributes. That is, they should correspond to attributes that define different variations of a product (e.g., color
, size
) rather than general product attributes.
Plugin API Endpoints
GET
List Plugins
GET
List PluginsThis endpoint retrieves the plugin settings stored in the database.
Path: /api/v1/plugins/
Example Request
Example Response
Response Parameters
pk
Contains the ID of the plugin.
key
Stores the KEY
attribute value of the plugin class.
name
Stores the NAME
attribute value of the plugin class.
description
Stores the DESCRIPTION
attribute value of the plugin class.
config
Contains the CONFIG
attribute value of the plugin.
default_config
Contains the DEFAULT CONFIG
attribute value of the plugin.
is_active
Indicates whether the plugin is active.
GET
List All Available Plugins
GET
List All Available PluginsThis endpoint retrieves all plugin classes registered in the Plugin Registry.
Path: /api/v1/plugins/all/
Example Request
Example Response
Response Parameters
key
Stores the KEY
attribute value of the plugin class.
name
Stores the NAME
attribute value of the plugin class.
description
Stores the DESCRIPTION
attribute value of the plugin class.
config
Contains the CONFIG
attribute value of the plugin.
is_active
Indicates whether the plugin is active.
POST
Create a Plugin
POST
Create a PluginThis endpoint is used to add settings and activate a plugin. Only one record can be created for each plugin key, and duplicate records are not allowed. If the provided key
does not exist in the Plugin Registry, the API returns an error: Plugin with this key does not exist.
The config
key in the request body must contain a dictionary formatted according to the config_serializer
defined in the plugin class.
Path: /api/v1/plugins/
Request Body Parameters
key
Must contain the KEY
attribute value of the plugin class.
config
Must contain a valid configuration according to the serializer.
is_active
Indicates whether the plugin is active.
Example Request
Example Response
Response Parameters
pk
Contains the ID of the plugin.
key
Stores the KEY
attribute value of the plugin class.
name
Stores the NAME
attribute value of the plugin class.
description
Stores the DESCRIPTION
attribute value of the plugin class.
config
Contains the CONFIG
attribute value of the plugin.
default_config
Contains the DEFAULT CONFIG
attribute value of the plugin.
is_active
Indicates whether the plugin is active.
PUT
Update a Plugin
PUT
Update a PluginThis endpoint updates the settings and activation status of an existing plugin. If a plugin has not been added previously, it must be created first.
The config
key in the request body must contain a dictionary formatted according to the config_serializer
defined in the plugin class.
Path: /api/v1/plugins/
Request Body Parameters
key
Must contain the KEY
attribute value of the plugin class.
config
Must contain a valid configuration according to the serializer.
is_active
Indicates whether the plugin is active.
Example Request
Example Response
Response Parameters
pk
Contains the ID of the plugin.
key
Stores the KEY
attribute value of the plugin class.
name
Stores the NAME
attribute value of the plugin class.
description
Stores the DESCRIPTION
attribute value of the plugin class.
config
Contains the CONFIG
attribute value of the plugin.
default_config
Contains the DEFAULT CONFIG
attribute value of the plugin.
is_active
Indicates whether the plugin is active.
Last updated
Was this helpful?