Attributes
This guide explains how Deducto uses attributes, the building blocks that power your promotion logic. Attributes are pieces of data about your products and cart that you can use in promotion rules. Think of them as properties or characteristics that you can check when deciding if a promotion should apply.
Types of attributes
Deducto organises attributes into three main categories: Core Attributes, Default Integration Attributes, and Custom Attributes. Additionally, attributes can be specific to products or the cart, allowing for fine-tuned control over your promotions.
Core attributes
Core Attributes are built-in data points essential to ecommerce operations and are available by default in all projects. These attributes require no additional configuration and can be used directly in promotion logic. You can view the complete list of available attributes when you set up your promotion logic.
Some core product attributes include:
- Product ID
- Name
- Final Price
- Is On Sale
Some core cart attributes include:
- Original Subtotal
- Discounted Subtotal
- Total Item Quantity
- Shipping Method Codes
Default integration attributes
These attributes are automatically set up based on your ecommerce platform integration, making them ready to use without any additional configuration. They are tailored to the platform you've connected with Deducto. Like Core Attributes, you can view the full list of available attributes when configuring your promotion logic.
Example default integration attributes for Shopify:
- Brand
- Categories
- Tags
WooCommerce support is coming soon. When the WooCommerce integration ships, it will provide its own default attributes (such as Categories, SKU, and Variant ID).
Custom attributes
Custom Attributes are user-defined and can apply at either the product or cart level. These attributes allow you to incorporate unique data points that suit your specific business needs.
Examples custom product attributes might include:
- Season
- Material
- Age Range
Examples custom cart attributes might include:
- Sales Channel
You can define custom attributes in a project's configurations. When setting one up, you choose its data type, whether it holds a single value or an array, and whether it's required on every request.
Data types
Each attribute, whether core, default or custom, has a data type. This dictates what kind of logic and checks you can use with them and what they can represent.
In most cases, choosing a type is simply a matter of matching it with your product data. Each type comes with recommended examples for common use cases.
The types Deducto offers are:
| Type | Description |
|---|---|
| Exact String | Exact string attributes hold strings that must match exactly. Best suited for values that aren't purely identifiers but should always be checked for a full exact match, such as product names. |
| Wildcard String | Wildcard String attributes hold strings that can have partial matches. For example, checking if a string contains, starts with, ends with, or doesn't contain some value. Use this for free-form text content or values that may be dynamically generated from parts (like dynamic slugs). |
| Membership | Membership types are used for ID-based indices/collections in Search Integrations. The entity's ID is stored and used in the promotion instead of raw values, so you can update the entity's name or other fields in your database without breaking the promotion. |
| Money | Money attributes hold monetary amounts and use proper rounding and precision when performing operations. |
| Optional | Optional attributes only check if the attribute is present or not, regardless of its value. |
| Integer | Integer attributes hold whole number values. Useful for counts or internal quantities of packs. |
| Decimal | Decimal attributes hold any real number. Useful for ratings and other fractional values. |
| Boolean | Boolean attributes hold true/false or yes/no values. Useful for membership status and other flags on products or carts. |
Array attributes
Array attributes are available for custom attributes and can hold multiple values of the selected type, unlike regular attributes which only hold a single value. They are useful for storing lists of data like a product's colors, categories, or related product IDs.
Array attributes are only available for the following types:
- Membership
- Exact String
- Wildcard String
When using array attributes, you can perform special array operations in your conditions, such as checking if the array "contains any of" or "contains all of" a set of values.
Compulsory or optional
When configuring an attribute, you can specify whether it is compulsory or optional. A compulsory attribute must be included in every API request to Deducto when calculating promotions for a cart item. If any compulsory attributes are missing from the cart item data, Deducto will reject the request entirely. This helps ensure that critical attributes needed for your promotion logic are always present.
For example, if you have promotions that rely on a product's "category" attribute to function correctly, you would want to make that attribute compulsory to prevent errors or unexpected behaviour.
Updated 9 days ago