> ## Documentation Index
> Fetch the complete documentation index at: https://www.alttextlab.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Craft Commerce

> Use product metadata to generate more accurate alt text for product images.

Craft Commerce support is part of the [AltTextLab Craft CMS plugin](/integrations/craftcms/overview). If you haven't set it up yet, start with [installation](/integrations/craftcms/installation) and [settings](/integrations/craftcms/settings).

AltTextLab automatically detects whether Craft Commerce is installed and enabled. If it is, a dedicated **Commerce** section appears in the plugin settings.

When an image is linked to a Commerce product or variant, the plugin reads product data — name, brand, color, material — and sends it to the AltTextLab API alongside the image. This allows the AI to generate more accurate, product-specific descriptions.

<Warning>
  Product context is only available during **bulk generation**. When an image is uploaded, Craft CMS has not yet linked it to a product or variant, so the plugin cannot read any Commerce data at that point. To generate Commerce-enriched alt text, use [bulk generation](/integrations/craftcms/usage) after the asset has been assigned to a product.

  If you use Craft Commerce, we recommend **disabling automatic generation** and running bulk generation instead, after you have updated your product catalog.
</Warning>

## How it works

1. At generation time, the plugin checks whether the asset is related to any Commerce variant or product.
2. If a linked variant is found, its parent product is resolved automatically.
3. The configured product fields — name, brand, color, material — are read and passed to the API as additional context.
4. If no linked product or variant is found, generation proceeds as usual without any extra context.

## Commerce settings

All Commerce settings are available under **AltTextLab → Settings → Commerce**.

### Product name for alt text

Controls which title is sent to the API as the product name:

* *Use product name* (default) — uses the title of the linked product.
* *Use variant title* — uses the title of the linked variant. Useful when each variant represents a distinct version of the product, for example a city poster sold in multiple cities: *"New York"*, *"Paris"*, *"Tokyo"*. Falls back to the product title if no variant is linked.

### Brand field handle

The handle of a Plain Text (or similar) field on the **product** that stores the brand name, for example `brand`. Leave empty to skip brand context entirely.

<Info>
  If your products have a field with handle `brand` containing *"Acme Co."*, enter `brand` here and the AI will receive that value as additional context.
</Info>

### Color source

Determines which element the color field is read from:

* *Use product color field* (default) — reads the color field from the product.
* *Use variant color field* — reads the color field from the variant. Useful for products where color is a variant-level attribute.

### Color field handle

The handle of the field that stores the color value, for example `color`. The field is read from the product or variant depending on the **Color source** setting. Leave empty to skip color context.

### Material source

Determines which element the material field is read from:

* *Use product material field* (default) — reads the material field from the product.
* *Use variant material field* — reads the material field from the variant.

### Material field handle

The handle of the field that stores the material value, for example `material`. The field is read from the product or variant depending on the **Material source** setting. Leave empty to skip material context.

<Tip>
  You can mix sources. For example, set **Product name** to *Use variant title*, **Color source** to *Use variant color field*, and **Material source** to *Use product material field* — the plugin reads each attribute from the appropriate element independently.
</Tip>
