Skip to content

Nutritional values

A food store must display a nutrition facts table (EU Regulation 1169/2011). Polski for WooCommerce lets you add a table to each product in a format compliant with regulations.

According to Article 30 of the FIC Regulation, the nutrition facts table must contain at least:

NutrientUnitJSON key
Energy valuekJ / kcalenergy_kj, energy_kcal
Fatgfat
of which saturated fatty acidsgsaturated_fat
Carbohydratesgcarbohydrates
of which sugarsgsugars
Proteingprotein
Saltgsalt

Additionally, the following can be provided (Art. 30(2) FIC):

NutrientUnitJSON key
Monounsaturated fatty acidsgmonounsaturated_fat
Polyunsaturated fatty acidsgpolyunsaturated_fat
Polyolsgpolyols
Starchgstarch
Fibregfibre
Vitamin Amcgvitamin_a
Vitamin Dmcgvitamin_d
Vitamin Emgvitamin_e
Vitamin Kmcgvitamin_k
Vitamin Cmgvitamin_c
Thiamine (B1)mgthiamine
Riboflavin (B2)mgriboflavin
Niacin (B3)mgniacin
Vitamin B6mgvitamin_b6
Folic acidmcgfolic_acid
Vitamin B12mcgvitamin_b12
Biotinmcgbiotin
Pantothenic acidmgpantothenic_acid
Potassiummgpotassium
Chloridemgchloride
Calciummgcalcium
Phosphorusmgphosphorus
Magnesiummgmagnesium
Ironmgiron
Zincmgzinc
Coppermgcopper
Manganesemgmanganese
Fluoridemgfluoride
Seleniummcgselenium
Chromiummcgchromium
Molybdenummcgmolybdenum
Iodinemcgiodine

Go to WooCommerce > Settings > Polski > Food and activate the “Nutritional Values” sub-module.

SettingDefaultDescription
Reference unitper 100 gDefault unit: per 100 g or per 100 ml
Display % RIYesReference intake (% of daily requirement)
Table positionTabWhere to display the table on the product page
Optional nutrientsFibre, vitaminsWhich optional nutrients to display

In the “Food” tab in the product editor, you will find the nutritional values form. Fill in fields with numeric values per 100 g or 100 ml.

Each product can have an individual reference unit. Beverages should have “per 100 ml” set, solid products - “per 100 g”. If not set, the default value from settings will be used.

Optionally, you can also provide serving size and nutritional values per serving:

FieldDescription
Serving sizee.g. “30 g”, “250 ml”, “1 slice (25 g)“
Servings per packagee.g. “10”

Nutritional values are stored in the database as JSON in the meta field _polski_nutrients. Format:

{
"energy_kj": 1046,
"energy_kcal": 250,
"fat": 9.5,
"saturated_fat": 3.2,
"carbohydrates": 31.0,
"sugars": 5.4,
"fibre": 2.1,
"protein": 8.7,
"salt": 1.2,
"ref_unit": "100g",
"serving_size": "30g",
"servings_per_package": 10
}
  • Values must be numbers (int or float)
  • Decimal separator in JSON: dot (e.g. 9.5)
  • Values cannot be negative
  • energy_kj and energy_kcal should be consistent (1 kcal = 4.184 kJ)
  • Sub-nutrients cannot exceed the parent nutrient (e.g. saturated_fat <= fat)

Use the shortcode [polski_nutrients] to display the nutrition facts table.

ParameterTypeDefaultDescription
product_idintcurrentProduct ID
show_rwsbooltrueWhether to display % RI
show_servingboolfalseWhether to display the per serving column
fieldsstringallNutrients to display (comma-separated)
layoutstringtableLayout: table, list, compact
wrapperstringdivWrapping HTML element

Full nutrition facts table:

[polski_nutrients]

With per serving values:

[polski_nutrients show_serving="true"]

Basic nutrients only:

[polski_nutrients fields="energy_kcal,fat,carbohydrates,protein,salt"]

Compact layout (without table):

[polski_nutrients layout="compact"]

For a specific product:

[polski_nutrients product_id="123" show_rws="true" show_serving="true"]

In a PHP template:

echo do_shortcode('[polski_nutrients product_id="' . $product->get_id() . '"]');

The shortcode generates a table compliant with the EU standard:

<div class="polski-nutrients">
<table class="polski-nutrients__table">
<thead>
<tr>
<th>Nutritional value</th>
<th>per 100 g</th>
<th>% RI*</th>
</tr>
</thead>
<tbody>
<tr>
<td>Energy value</td>
<td>1046 kJ / 250 kcal</td>
<td>13%</td>
</tr>
<tr>
<td>Fat</td>
<td>9.5 g</td>
<td>14%</td>
</tr>
<tr class="polski-nutrients__sub">
<td>of which saturated fatty acids</td>
<td>3.2 g</td>
<td>16%</td>
</tr>
<!-- ... -->
</tbody>
<tfoot>
<tr>
<td colspan="3">
* Reference intake for an average adult (8400 kJ / 2000 kcal)
</td>
</tr>
</tfoot>
</table>
</div>

The plugin calculates % RI automatically based on reference values from Annex XIII of the FIC Regulation:

NutrientReference value
Energy8400 kJ / 2000 kcal
Fat70 g
Saturated fatty acids20 g
Carbohydrates260 g
Sugars90 g
Protein50 g
Salt6 g
Fibre25 g
$nutrients_json = get_post_meta($product_id, '_polski_nutrients', true);
$nutrients = json_decode($nutrients_json, true);
if ($nutrients) {
$energy_kcal = $nutrients['energy_kcal'] ?? 0;
$protein = $nutrients['protein'] ?? 0;
}
$nutrients = [
'energy_kj' => 1046,
'energy_kcal' => 250,
'fat' => 9.5,
'saturated_fat' => 3.2,
'carbohydrates' => 31.0,
'sugars' => 5.4,
'protein' => 8.7,
'salt' => 1.2,
'ref_unit' => '100g',
];
update_post_meta($product_id, '_polski_nutrients', wp_json_encode($nutrients));
add_filter('polski/nutrients/values', function (array $nutrients, int $product_id): array {
// Rounding values according to EU guidelines
if (isset($nutrients['energy_kcal'])) {
$nutrients['energy_kcal'] = round($nutrients['energy_kcal']);
}
return $nutrients;
}, 10, 2);

The polski_nutrients column in CSV should contain values in JSON format:

"Fruit muesli","{""energy_kj"":1590,""energy_kcal"":380,""fat"":8.2,""saturated_fat"":1.5,""carbohydrates"":64.0,""sugars"":22.0,""fibre"":7.5,""protein"":9.8,""salt"":0.05,""ref_unit"":""100g""}"

Quotation marks inside JSON must be doubled ("") in the CSV file.

.polski-nutrients__table {
width: 100%;
border-collapse: collapse;
font-size: 0.9em;
}
.polski-nutrients__table th,
.polski-nutrients__table td {
padding: 0.4em 0.8em;
border-bottom: 1px solid #e0e0e0;
text-align: left;
}
.polski-nutrients__sub td:first-child {
padding-left: 1.5em;
font-style: italic;
}
.polski-nutrients__table tfoot td {
font-size: 0.8em;
color: #666;
padding-top: 0.8em;
}
  1. Check that the nutritional values sub-module is enabled
  2. Make sure the product has the _polski_nutrients field filled with valid JSON
  3. Verify JSON format - use a validator (e.g. jsonlint.com)

Values display with a dot instead of comma

Section titled “Values display with a dot instead of comma”

The plugin automatically formats numbers according to Polish settings (decimal comma). If you see a dot, check that the WordPress locale is set to pl_PL.

Check that the “Display % RI” option is enabled in settings and that the show_rws parameter in the shortcode is not set to false.

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.