A passport's fields are not fixed: they come from a template, one per sector, and the regulation's delegated acts will define a different set of data for each product group. DPTag keeps the templates as configuration, so a new act or a new sector means a template update and not a rewrite, and every template ships in the free plugin.
The templates today
| Template | Label in the admin | Fields |
|---|---|---|
textile | Textile and apparel | 12 fields in 5 groups, listed here |
furniture | Furniture | 14 fields in 5 groups, listed here |
The first template registered is the default one: a product that matches nothing gets the textile template. Sectors are never a paid feature. Each new template, batteries or mattresses for instance, ships in the free plugin on wordpress.org as it is written, because gating a sector would shut out the shops of that sector instead of serving them.
How a product is attributed to a sector
Each template declares detection signals of three kinds, and a product is scored against every template on your site, without any network call:
| Signal | Compared with | Weight |
|---|---|---|
| Category words | The names and slugs of the product's categories | 4 per match |
| Attribute names | The names of the product's WooCommerce attributes | 2 per match |
| Keywords | The product's name, short description and description | 1 per match |
Comparison ignores case and accents, and each signal counts once however often it appears. The template with the highest score wins; with every score at zero, the default template is used. The signals are in English and French, "clothing", "vêtement", "chair", "chaise" and so on, and a category match outweighs two keyword matches on purpose: a shop's categories say what a product is more reliably than the words of its description.
Detection runs when a passport is created. It also decides, from a sample of the newest hundred products, which sector the setup wizard shows first and which sector each category leans to.
Switching a passport's sector
The sector of a passport is shown in its editor and can be changed there. Switching redraws the form with the other template's fields. Values whose field key exists in both templates, the composition, the country of origin or the recycling instructions for instance, carry over; the rest stays stored but is not shown until the passport returns to a template that has the field.
The sector also selects which store defaults apply, since defaults are set per template under Passports, then Defaults.
What a template holds
For each field, a template gives its label, its type, whether it is required, an optional help text, and whether it can carry a default. The types are:
- text, one line;
- textarea, several lines of prose, translatable;
- country, a country name;
- number, a numeric value, set in the monospaced face on the public page;
- materials, the list of materials with percentages that draws the composition bar.
Required fields are the ones the completeness score counts. A field marked as not defaultable, the batch number, is by nature unique to one item and is never offered on the defaults screens.
Templates can be extended by another plugin through a filter, described on the hooks page.