Product Types

Product Types are a way to distinguish products in your system. They can determine the URL format of a product, whether it has multiple variants, and configure other product behaviors.

You can also attach fields and tab layouts to Product Types just like you can with Craft’s Entry Types (opens new window).

Edit Product Type page

# Product Type Options

# Name

The name of the product type as displayed in the control panel.

# Handle

The handle is what you’ll use to reference the product type in code. In Twig, for example, to get your product types with a handle of clothes you would use:

{% set clothes = craft.products.type('clothes').all() %}

# Title Field Label

Allows you to change what the “Title” field label should be.

# Automatic SKU Format

Defines what auto-generated SKUs should look like when a SKU field is submitted empty. You can include Twig tags that output properties, such as {product.slug} or {myCustomField}.

How you access properties in the SKU format depends on whether the product type has variants. If the product type does not have multiple variants, use {product}. Otherwise, {object} will refer to the variant when the product type has multiple variants.

Be sure to choose this carefully and avoid using the id property to ensure a unique SKU.

Since id refers to the element’s ID and Craft may have many other elements, this won’t be sequential. If you’d rather generate a unique sequential number, consider using Craft’s seq() (opens new window) Twig function, which generates a next unique number based on the name parameter passed to it.

The following example generates a sequential number, per variant, with the given product slug:

{{ object.product.slug }}-{{ seq(object.product.slug) }}

The resulting variant SKU might be something like a-new-toga-001, where a-new-toga is the product’s slug and 001 is the first sequential number based on that slug.

If a product type has an automatic SKU format, the SKU field is not shown for new variants. Once saved, the field will be displayed for editing.

# Order Description Format

Describes the product on a line item in an order. It can include tags that output properties, such as {product.title} or {myVariantCustomField}.

# Show the Dimensions and Weight fields

Allows you to hide the weight and dimensions fields if they are not necessary for products of this type.

# Products of this type have multiple variants

If enabled and multiple variants are allowed, a new tab will appear at the top of the page for configuring the variant field layout.

A “Variant Title Format” will also appear for configuring auto-generated variant titles.

# Show the Title field for variants

Whether or not to show the “Variant Title” field when adding or editing variants. When true a “Variant Title Field Label” will appear, allowing you to change what the “Variant Title” field label should be.

# Products of this type have their own URLs

This works just like Craft’s entry (opens new window) URLs.

When a site visitor hits the URL of a product, the product variable is automatically available to your templates, just like the entry variable for Craft’s entries.