Widgets
Widgets are dynamic UI components based on schemas, encompassing elements like sliders and banners that are deployable within the storefront. These elements can also store information regarding product collections and can be used for displaying products on the storefront. Widgets are formally defined within Omnitron and can be retrieved by querying them using their unique widget slug identifier.
Model
Widget
field | type | description |
---|---|---|
name | CharField | The name of the widget. |
slug | SlugField | A unique slug for identifying the widget. |
template | SlugField | The template used for rendering the widget. |
widget_type | WidgetType | The widget type that holds the widget's schema. |
created_date | DateTimeField | The date when the widget was created. |
modified_date | DateTimeField | The date when the widget was last modified. |
attributes | JSONField | Attributes of the widget. |
attributes_kwargs | JSONField | Information about the widget's attributes. |
content_type | ContentType | The content type of the widget. |
localized_attributes | JSONField | Localized attributes specific to the widget. |
localized_attributes_kwargs | JSONField | Information about localized attributes. |
ProductCollectionWidget
field | type | description |
---|---|---|
name | CharField | The name of the widget. |
slug | SlugField | A unique slug for identifying the widget. |
template | SlugField | The template used for rendering the widget. |
product_collection | ProductCollection | The product collection linked to the widget. |
product_limit | PositiveIntegerField | The maximum number of products to display in the widget. |
widget_type | WidgetType | The widget type that holds the widget's schema. |
created_date | DateTimeField | The date when the widget was created. |
modified_date | DateTimeField | The date when the widget was last modified. |
attributes | JSONField | Attributes of the widget. |
attributes_kwargs | JSONField | Information about the widget's attributes. |
content_type | ContentType | The content type of the widget. |
localized_attributes | JSONField | Localized attributes specific to the widget. |
localized_attributes_kwargs | JSONField | Information about localized attributes. |
Endpoints
GET
Retrieve a Widget Info
This method is used to get widget information that have been defined in Omnitron.
Path: https://{commerce_url}/widgets/<widget-slug>/
Example Response
Here's an example response of a product collection widget:
{
"name": "Campaign",
"slug": "x-campaign",
"attributes": {
"abc": "xyz"
},
"template": "widgets/campaign.html",
"products": [
{
"pk": 10,
"sku": "12612662136",
...
},
{
"pk": 11,
"sku": "12612662137",
...
},
....
]
}
Here's an example response of a simple widget:
{
"attributes": {
"sliders": [
{
"value": {
"name": "Kampanya",
"slug": "kampanya"
},
"kwargs": null
},
{
"value": {
"name": "\u0130ndirim",
"slug": "indirim"
},
"kwargs": null
}
],
"slider_items": [
{
"value": {
"url": "#",
"slider_slug": "kampanya",
"alt": "resim",
"image": "assets/img/slider.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "indirim",
"alt": "resim",
"image": "assets/img/slider2.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "kampanya",
"alt": "resim",
"image": "assets/img/slider2.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "indirim",
"alt": "resim",
"image": "assets/img/slider.jpg",
"title": "baslik"
},
"kwargs": null
}
]
},
"name": "Slider",
"template": "index/slider.html",
"slug": "slider"
}