Skip to content

Allergens

EU regulations require labeling 14 allergens on food product labels. In an online store, allergen information must be visible before purchase. Polski for WooCommerce handles allergens through a WordPress taxonomy.

According to Annex II of the FIC Regulation, mandatory declaration covers:

NoAllergenTaxonomy slugIcon
1Cereals containing glutenglutengluten
2Crustaceanscrustaceanscrustaceans
3Eggseggseggs
4Fishfishfish
5Peanutspeanutspeanuts
6Soybeanssoysoy
7Milk (lactose)milkmilk
8Nutsnutsnuts
9Celerycelerycelery
10Mustardmustardmustard
11Sesame seedssesamesesame
12Sulphur dioxide and sulphitessulphitessulphites
13Lupinlupinlupin
14Molluscsmolluscsmolluscs

The plugin registers the polski_allergen taxonomy associated with the product post type. During plugin activation, the taxonomy is automatically populated with the 14 main allergens.

Go to Products > Allergens to manage the allergen list. The default 14 allergens are created automatically. You can add custom allergens specific to your product range.

Each allergen contains:

FieldDescription
NameDisplayed allergen name (e.g. “Milk and dairy products”)
SlugURL identifier (e.g. milk)
DescriptionAdditional information about the allergen
IconOptional icon (taxonomy thumbnail)

In the product editor, in the “Food” tab or in the “Allergens” side panel, check the appropriate allergens from the checkbox list.

Three declaration modes are available:

ModeDescriptionExample
ContainsProduct contains the allergen”Contains: milk, eggs”
May containCross-contamination risk”May contain: nuts”
Does not containExplicit absence declaration (optional)“Does not contain: gluten"

The “May contain” mode is used to indicate the risk of trace amounts of an allergen resulting from production processes. In the product editor, each allergen can be marked as:

  • Contains - allergen is a product ingredient
  • May contain - risk of trace amounts

Go to WooCommerce > Settings > Polski > Food and configure the “Allergens” section.

SettingDefaultDescription
Enable allergen declarationYesActivates the allergen system
Highlight in ingredientsYesAutomatic bolding of allergens in the ingredients list
Show iconsNoDisplay allergen icons
Position on pageFood tabWhere to display allergens
”May contain” modeYesEnables the trace amounts declaration option
Display formatListlist, icons, inline

According to Article 21 of the FIC Regulation, allergens in the ingredients list must be highlighted - usually by bolding or using capital letters. The plugin automatically searches for allergen names in the “Ingredients” field and wraps them in a <strong> tag.

Example:

Input text:

Wheat flour, sugar, butter, chicken eggs, skimmed milk powder, salt

Displayed text:

Wheat flour (gluten), sugar, butter (milk), chicken eggs, skimmed milk powder, salt

With HTML highlighting:

<strong>Wheat</strong> flour (<strong>gluten</strong>), sugar, butter (<strong>milk</strong>),
<strong>eggs</strong>, <strong>milk</strong> powder, salt

The plugin searches the ingredients list for allergen synonyms. The synonym list is configurable:

add_filter('polski/allergens/synonyms', function (array $synonyms): array {
$synonyms['gluten'] = ['pszenica', 'pszenna', 'żyto', 'żytnia', 'owies', 'owsiana', 'jęczmień', 'orkisz'];
$synonyms['milk'] = ['mleko', 'mleczny', 'mleczna', 'masło', 'śmietana', 'jogurt', 'ser', 'laktoza'];
$synonyms['eggs'] = ['jaja', 'jajka', 'jajeczny', 'jajeczna'];
return $synonyms;
});

Use the shortcode [polski_allergens] to display the allergen declaration.

ParameterTypeDefaultDescription
product_idintcurrentProduct ID
formatstringlistFormat: list, icons, inline, table
show_may_containbooltrueWhether to display the “May contain” section
show_iconsboolfalseWhether to display allergen icons
labelstring"Allergens: "Label before the list
wrapperstringdivWrapping HTML element

Basic allergen list:

[polski_allergens]

Result:

Allergens: milk, eggs, gluten
May contain: nuts

Inline format with icons:

[polski_allergens format="inline" show_icons="true"]

Without “May contain” section:

[polski_allergens show_may_contain="false"]

Table format:

[polski_allergens format="table"]

For a specific product:

[polski_allergens product_id="456"]

In a PHP template:

echo do_shortcode('[polski_allergens product_id="' . $product->get_id() . '"]');
// "Contains" allergens
$allergens = wp_get_object_terms($product_id, 'polski_allergen');
foreach ($allergens as $allergen) {
echo $allergen->name; // e.g. "Milk and dairy products"
}
// "May contain" allergens
$may_contain = get_post_meta($product_id, '_polski_may_contain_allergens', true);
if ($may_contain) {
$may_contain_terms = get_terms([
'taxonomy' => 'polski_allergen',
'slug' => $may_contain,
]);
}
// Setting "Contains" allergens
wp_set_object_terms($product_id, ['gluten', 'milk', 'eggs'], 'polski_allergen');
// Setting "May contain" allergens
update_post_meta($product_id, '_polski_may_contain_allergens', ['nuts', 'soy']);

Checking if a product contains an allergen

Section titled “Checking if a product contains an allergen”
if (has_term('gluten', 'polski_allergen', $product_id)) {
// Product contains gluten
}

Allergens can be imported via CSV:

CSV columnDescriptionFormat
polski_allergens”Contains” allergensSlugs separated by commas
polski_may_contain”May contain” allergensSlugs separated by commas

Example:

"Butter cookies","gluten,milk,eggs","nuts,soy"
"Orange juice","",""
.polski-allergens {
margin: 1em 0;
padding: 0.8em;
background: #fff3e0;
border: 1px solid #ffcc02;
border-radius: 4px;
}
.polski-allergens__label {
font-weight: 700;
color: #e65100;
}
.polski-allergens__list {
list-style: none;
padding: 0;
display: flex;
flex-wrap: wrap;
gap: 0.5em;
}
.polski-allergens__item {
display: inline-flex;
align-items: center;
gap: 0.3em;
padding: 0.2em 0.6em;
background: #fff;
border: 1px solid #ffcc02;
border-radius: 3px;
font-size: 0.9em;
}
.polski-allergens__may-contain {
margin-top: 0.5em;
font-style: italic;
color: #666;
}
.polski-allergens__icon {
width: 20px;
height: 20px;
}

Allergens do not display on the product page

Section titled “Allergens do not display on the product page”
  1. Check that the allergens module is enabled
  2. Make sure the product has allergens assigned in the editor
  3. Verify that the polski_allergen taxonomy is correctly registered (Products > Allergens)
  1. Check that the “Highlight in ingredients” option is enabled
  2. Make sure allergen names or their synonyms match the text in the ingredients list
  3. Extend the synonym list with the polski/allergens/synonyms filter

Default allergens missing after activation

Section titled “Default allergens missing after activation”

If the 14 allergens list was not created automatically, go to WooCommerce > Settings > Polski > Food and click “Create default allergens”.

This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.