Variant

Product variant model schema

Product variants are custom variations of a specific product. They are typically pre-determined sizes, colors, packages, etc available the shopper as options no the product page before adding the product to a shopper's cart.

Attributes

Attribute

Type

Example

Description

id

*required

String or Integer

"product-123"

Your platform's ID of the variant.

name

*required

String

"Product 123"

Name or title of the product variation as it appears in the custom options list. Do not include the product name in this value.

url

optional

String

https://a.co /p123/v1

URL to the product variation in the store's frontend if it is different than the product's URL (this attribute is not normally used)

thumbnail_url

optional

String

https://cdn.b.co /p123/v1/i.png

URL to the product variation thumbnail image that can be displayed if it is different than the product's thumbnail image.

status

optional

String

"published", "draft"

The status of the variant. If draft then the product will be treated as unpublished.

Default: published

price

optional

Float

99.89

Regular price of the product.

created_at

optional

ISO 8601 format DateTime String

"2019-03-18T21:01:10+00:00"

Date the variant was created in the store/platform system

Default: Current date/time when variiant first seen by Fera

modified_at

optional

ISO 8601 format DateTime String

"2019-03-18T21:01:10+00:00"

Date the variant was last modified in the store/platform system

Default: Value ofcreated_at

stock

optional

Integer

5

The amount of inventory available for the current variant.

Default: unlimited

in_stock

optional

Boolean

true, false

Whether or not the variant is current in or out of stock.

Default: true

needs_shipping

optional

Boolean

true, false

Whether or not this variant needs to be shipped (is it digital?)

Default: false

hidden

optional

Boolean

true, false

Is this variant hidden from your store/platform's catalog, collection, category and/or search views?

Default: false

platform_data

optional

Hash/Object

{ foo: "bar" }

This field allows you to store some extra attributes about the variant that can later be referenced that are not part of the list above.

Sample Payload

{
"id": "variant-123", // String
"name": "Variation 123", // String
"status": "published", // (Optional) String
"price": 99.89, // (Optional) Float
"created_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"modified_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"stock": 123, // (Optional) Integer, If null assumed to be infinite.
"in_stock": true, // (Optional) Boolean
"url": "https://www.example.com/products/product-123", // String
"thumbnail_url": "https://cdn.example.com/products/product-123/image.png", // String
"needs_shipping": true, // (Optional) Boolean
"hidden": false, // (Optional) Boolean
"variants": [Variant], // (Optional) Array<Variant>: Variants that are applicable to this product.
"platform_data": { "any": "data" } // (Optional) Hash/Object of attributes to store about the product specific to the integration platform (can be used in future filters)
}

How Variants Are Handled

Fera will fall back on product attributes in the variants array if data cannot be found in on of the attributes listed above. For example, if an request specifies the specific variant_id when requesting things like in_stock then Fera will first look in the variant for the data. If the variant did not specify the data then it falls back to the product data.

It also works the other way too. If a request for in_stock is made on the product with no specific variant_id then Fera will first look in the product attributes. If product attributes do not specify an in_stock status then it will look to see if any variants are in_stock. If so, it will return true, otherwise, false.