The "Price Calculations" plugin will allow you to recalculate the price of the product based on what the customer enters / selects on the product page.
Features
- Define formulas to calculate product prices based on customer input (custom item fields), product data, or fixed values.
- Multiple formulas with conditions: the plugin uses the first formula whose condition matches.
- Automatic tax handling with fine-grained control via
:notax, :withtax, and :optional modifiers.
- Supports characteristics/variants (the
{price} tag reflects the selected variant's price).
- Supports product options (the
{price} tag includes option costs).
- Live price preview on the product page via AJAX, updating as the customer changes fields.
- Detailed calculation metadata exposed on the product object for use in view overrides and JavaScript.
Installation
Easy and quick !
- Download the plugin on our website
- Install it on your Joomla website (extension manager)
- Enable the "HikaShop Price calculations" plugin via the Joomla plugins manager
- Edit the plugin and enter the different formulas you want to use in it.
Usage
- This HikaShop Price Calculations plugin is compatible with all the editions of HikaShop
- HikaShop 5.1.0 or newer required, HikaShop 6.4.0 or newer for calculation metadata
- Compatible with PHP 7.4 minimum
- GPL v3
- No limit of time
- No limit of use
Backend settings
Frontend result
Building formulas
Formulas are mathematical expressions that can reference product data, custom fields, and the current price. You can add several formulas in the plugin settings. For each product, the plugin evaluates them in order and uses the first one whose condition (if any) is met.
Available tags:
{price} : the product's unit price (takes into account the selected variant and options)
{product_quantity}, {cart_product_quantity} : stock or cart quantity
{fieldname} : any product custom field or item custom field by its column name (e.g. {product_width}, {product_height}, {product_weight}, or custom fields like {material_surcharge})
{currency_id} : the ID of the currency in which the price is currently displayed (useful in conditions to apply different formulas per currency)
{currency_rate} : the exchange rate of the current display currency relative to the main currency (e.g. 1 for USD if USD is the main currency, 24 for CZK if 1 USD = 24 CZK). Use this to make fixed amounts scale with currency conversion.
- Numbers (integers and decimals), operators (
+, -, *, /), parentheses
- PHP functions:
abs(), strlen(), mb_strlen(), substr(), trim(), str_word_count(), boolval(), empty(), decimal()
Tag modifiers:
{field:notax} : prevents tax from being applied to this field's value
{field:withtax} : forces tax to be applied even if the field is auto-detected as non-price (like a quantity)
{field:optional} : if the field is empty or missing, use 0 instead of skipping the formula
{field:optional:5} : same, but use 5 as the default value
- Modifiers can be combined:
{surcharge:optional:0:notax}
Examples:
{product_width} * {product_height} * 0.5 + {price} : area-based pricing added to the base price
{price} * {cart_product_quantity} * 0.9 : 10% discount applied to total
{price} + {engraving_fee:optional:0:notax} : optional flat fee without tax
{price} + (10 * {currency_rate}) : adds a 10 main-currency surcharge that scales with the display currency (e.g. +$10 USD or +240 CZK when 1 USD = 24 CZK)
Multi-currency conditions:
You can use {currency_id} in conditions to apply different formulas depending on the customer's currency. For example, use condition {currency_id} == 2 to match CZK only, with a fallback formula (no condition) for all other currencies.
Conditions:
Each formula can have a condition. The condition uses the same tags and is evaluated as a boolean expression. If it returns false, the formula is skipped and the next one is tried. Example condition: {product_width} > 0 or {material} == 'premium'.
Calculation metadata for view overrides
When the plugin calculates a price, it stores detailed metadata on the product object at $product->price_calculation. This data is available in any HikaShop view override (cart, checkout, order, etc.) and can be used to display a breakdown of the calculation.
Available properties:
$product->price_calculation->formula : the original formula template (e.g. {product_width} * {product_height} * 10 + {price})
$product->price_calculation->formula_resolved : the formula with values substituted (e.g. 50 * 30 * 10 + 25.00)
$product->price_calculation->price_before / price_before_with_tax : the price before calculation
$product->price_calculation->price_after / price_after_with_tax : the final calculated price
$product->price_calculation->taxes : the tax rates applied
$product->price_calculation->fields : array of field details (see below)
Each entry in the fields array contains:
name : the field name (e.g. "product_width")
raw_value : the original value from the product or customer input
resolved_value : the numeric value before tax
taxed : boolean, whether tax was applied to this field's value
tax_id : the tax category ID used (when taxed)
value_used : the final value used in the formula (after tax if applicable)
Example view override (cart):
if(!empty($product->price_calculation->fields)) {
echo '<ul class="calculation_breakdown">';
foreach($product->price_calculation->fields as $field) {
echo '<li>' . $field->name . ': ' . $field->raw_value;
if($field->taxed) echo ' (incl. tax)';
echo '</li>';
}
echo '</ul>';
}
JavaScript integration
On the product page, the plugin makes an AJAX call each time the customer changes a field value. The response includes the calculated price and full metadata, which you can use in custom JavaScript.
Listening to calculation updates:
The plugin calls window.hikashop.refreshCalculatedPrice when fields change. You can register your own listener via the HikaShop AJAX event system:
window.Oby.registerAjax(['hkContentChanged'], function(params) {
// Triggered after variant selection or field change
// The calculated price div has already been updated at this point
});
AJAX response format:
The AJAX response is a JSON object with:
price : formatted price string (respects the "Show taxed price" setting)
price_with_tax : formatted price with tax
price_without_tax : formatted price without tax
price_value : raw numeric price value
price_value_with_tax : raw numeric price with tax
formula : the formula object that was used
calculation : the full calculation metadata (same structure as $product->price_calculation on the server side)
Example: custom price display with breakdown:
// Override the default price update to add a breakdown
var originalRefresh = window.hikashop.refreshCalculatedPrice;
window.hikashop.refreshCalculatedPrice = function() {
// Call the original function first
var form = document.querySelector('form[name="hikashop_product_form"]');
if(!form) return;
var formData = window.Oby.getFormData(form, false);
var data = window.Oby.encodeFormData({formData: JSON.stringify(formData)});
window.hikashop.xRequest(calculationUrl, {mode:'POST', data:data}, function(xhr) {
var resp = Oby.evalJSON(xhr.responseText);
// Display the price
var html = resp.price;
// Add breakdown if calculation data is available
if(resp.calculation && resp.calculation.fields) {
html += '<ul>';
resp.calculation.fields.forEach(function(f) {
html += '<li>' + f.name + ': ' + f.raw_value + '</li>';
});
html += '</ul>';
}
document.getElementById('hikashop_product_price_with_options_main').innerHTML = html;
});
};
Changelog
2.4.0 on the 18th of March 2026
- Added
{currency_rate} tag: the exchange rate of the current display currency relative to the main currency. Use it to make fixed surcharges scale with currency, e.g. {price} + (10 * {currency_rate}) adds $10 in USD or 240 CZK when the rate is 24.
- Added
{currency_id} tag: the ID of the current display currency. Use it in conditions to apply different formulas per currency, e.g. condition {currency_id} == 2.
2.3.0 on the 18th of March 2026
- The plugin now exposes detailed calculation metadata on the product object ($product->price_calculation) including the original and resolved formula, price before/after calculation, tax info, and a breakdown of each field used with its raw value, resolved value, and whether tax was applied. This data is available in view overrides to display field contributions as separate lines in the cart or checkout.
- The AJAX calculation response now includes raw numeric price values (price_value and price_value_with_tax) and the full calculation metadata, making it easier to build custom frontend displays.
2.2.0 on the 16th of January 2026
- We've added automatic whitelist detection for non-price fields (quantities, IDs, counts) to prevent incorrect taxation in formulas.
- We've added :optional:VALUE modifier to allow formulas with optional custom fields that may not be set on all products.
- We've added :notax modifier to force taxation on fields when needed.
- We've added :withtax modifier to force taxation on whitelisted fields (quantities, IDs, counts) when needed.
- We've improved formula documentation with explanations of all available modifiers.
2.1.3 on the 2nd of December 2025
- The calculations plugin now takes into account the "Show taxed price" setting of the HikaShop configuration and it will display the calculated price based on this setting.
2.1.2 on the 4th of November 2025
- The calculations plugin now has a notes text area where you can write some text for each formula.
2.1.1 on the 29th of September 2025
- Checkbox custom item fields were not handled properly by the price calculations plugin.
2.1.0 on the 22th of September 2025
- The plugin can now work even if the product doesn't have any price already set for it.
- The plugin now returns the formula used to the javascript on the product page together with the calculated price. This way, the javascript can potentially act upon that formula.
- The plugin now supports providing a fixed number without tags in the formula field.
- We fixed an error with the calculation of the price on the product page in some cases with PHP 8.2 and higher.
- The plugin includes French, Japanese and Dutch translations.
2.0.0 on the 31st of March 2025
- The price calculations plugin now supports conditions on the formulas in order to allow for greater flexibility.
1.0.7 on the 16th of February 2024
- When several formulas would use the same custom item field and taxes would be calculated on the values of the custom item field, if the matching formula would not be the first one, the plugin would previously add the tax on the custom item field value once per formula before the matching formula.
1.0.6 on the 10th of January 2024
- When a custom item field is of the checkbox or multiple dropdown type, if the user selects several choices, the value of each choice selected will now be summed up to become the value of the field in the formula of the price calculations plugin. So basically, if someone selects option A with a value of 2, and option B with a value of 3, and the product has a base price of 10, if the formula is {price}+{customfield} the result will be 10+(2+3) = 15
1.0.5 on the 26th of October 2023
- On the product details page, the calculated price could be calculated with the values coming from the custom fields not taking into account the taxes even though it should be with taxes for products with variants in some cases.
1.0.4 on the 15th of September 2023
- On the product details page, the calculated price could be without taxes even though it should be with taxes for products with variants in some cases.
1.0.3 on the 23rd of august 2023
- The plugin didn't apply the formula properly on the product page when the {cart_product_quantity} tag was used and the quantity input of the product was hidden.
- We've added the boolval and empty functions support to the calculations plugin.
1.0.2 on the 11th of July 2023
- We've fixed a calculation issue on the product page in some cases.
1.0.1 on the 16th of September 2022
- The price calculations plugin now properly take into account the options selected on the product page for the calculated price display.
- We fixed an issue when having several products using the same formula in the cart.
1.0.0 on the 11th June 2022
- Initial release of the plugin
The "Price Calculations" plugin will allow you to recalculate the price of the product based on what the customer enters / selects on the product page.
Features
- Define formulas to calculate product prices based on customer input (custom item fields), product data, or fixed values.
- Multiple formulas with conditions: the plugin uses the first formula whose condition matches.
- Automatic tax handling with fine-grained control via
:notax, :withtax, and :optional modifiers.
- Supports characteristics/variants (the
{price} tag reflects the selected variant's price).
- Supports product options (the
{price} tag includes option costs).
- Live price preview on the product page via AJAX, updating as the customer changes fields.
- Detailed calculation metadata exposed on the product object for use in view overrides and JavaScript.
Installation
Easy and quick !
- Download the plugin on our website
- Install it on your Joomla website (extension manager)
- Enable the "HikaShop Price calculations" plugin via the Joomla plugins manager
- Edit the plugin and enter the different formulas you want to use in it.
Usage
- This HikaShop Price Calculations plugin is compatible with all the editions of HikaShop
- HikaShop 5.1.0 or newer required, HikaShop 6.4.0 or newer for calculation metadata
- Compatible with PHP 7.4 minimum
- GPL v3
- No limit of time
- No limit of use
Backend settings
Frontend result
Building formulas
Formulas are mathematical expressions that can reference product data, custom fields, and the current price. You can add several formulas in the plugin settings. For each product, the plugin evaluates them in order and uses the first one whose condition (if any) is met.
Available tags:
{price} : the product's unit price (takes into account the selected variant and options)
{product_quantity}, {cart_product_quantity} : stock or cart quantity
{fieldname} : any product custom field or item custom field by its column name (e.g. {product_width}, {product_height}, {product_weight}, or custom fields like {material_surcharge})
{currency_id} : the ID of the currency in which the price is currently displayed (useful in conditions to apply different formulas per currency)
{currency_rate} : the exchange rate of the current display currency relative to the main currency (e.g. 1 for USD if USD is the main currency, 24 for CZK if 1 USD = 24 CZK). Use this to make fixed amounts scale with currency conversion.
- Numbers (integers and decimals), operators (
+, -, *, /), parentheses
- PHP functions:
abs(), strlen(), mb_strlen(), substr(), trim(), str_word_count(), boolval(), empty(), decimal()
Tag modifiers:
{field:notax} : prevents tax from being applied to this field's value
{field:withtax} : forces tax to be applied even if the field is auto-detected as non-price (like a quantity)
{field:optional} : if the field is empty or missing, use 0 instead of skipping the formula
{field:optional:5} : same, but use 5 as the default value
- Modifiers can be combined:
{surcharge:optional:0:notax}
Examples:
{product_width} * {product_height} * 0.5 + {price} : area-based pricing added to the base price
{price} * {cart_product_quantity} * 0.9 : 10% discount applied to total
{price} + {engraving_fee:optional:0:notax} : optional flat fee without tax
{price} + (10 * {currency_rate}) : adds a 10 main-currency surcharge that scales with the display currency (e.g. +$10 USD or +240 CZK when 1 USD = 24 CZK)
Multi-currency conditions:
You can use {currency_id} in conditions to apply different formulas depending on the customer's currency. For example, use condition {currency_id} == 2 to match CZK only, with a fallback formula (no condition) for all other currencies.
Conditions:
Each formula can have a condition. The condition uses the same tags and is evaluated as a boolean expression. If it returns false, the formula is skipped and the next one is tried. Example condition: {product_width} > 0 or {material} == 'premium'.
Calculation metadata for view overrides
When the plugin calculates a price, it stores detailed metadata on the product object at $product->price_calculation. This data is available in any HikaShop view override (cart, checkout, order, etc.) and can be used to display a breakdown of the calculation.
Available properties:
$product->price_calculation->formula : the original formula template (e.g. {product_width} * {product_height} * 10 + {price})
$product->price_calculation->formula_resolved : the formula with values substituted (e.g. 50 * 30 * 10 + 25.00)
$product->price_calculation->price_before / price_before_with_tax : the price before calculation
$product->price_calculation->price_after / price_after_with_tax : the final calculated price
$product->price_calculation->taxes : the tax rates applied
$product->price_calculation->fields : array of field details (see below)
Each entry in the fields array contains:
name : the field name (e.g. "product_width")
raw_value : the original value from the product or customer input
resolved_value : the numeric value before tax
taxed : boolean, whether tax was applied to this field's value
tax_id : the tax category ID used (when taxed)
value_used : the final value used in the formula (after tax if applicable)
Example view override (cart):
if(!empty($product->price_calculation->fields)) {
echo '<ul class="calculation_breakdown">';
foreach($product->price_calculation->fields as $field) {
echo '<li>' . $field->name . ': ' . $field->raw_value;
if($field->taxed) echo ' (incl. tax)';
echo '</li>';
}
echo '</ul>';
}
JavaScript integration
On the product page, the plugin makes an AJAX call each time the customer changes a field value. The response includes the calculated price and full metadata, which you can use in custom JavaScript.
Listening to calculation updates:
The plugin calls window.hikashop.refreshCalculatedPrice when fields change. You can register your own listener via the HikaShop AJAX event system:
window.Oby.registerAjax(['hkContentChanged'], function(params) {
// Triggered after variant selection or field change
// The calculated price div has already been updated at this point
});
AJAX response format:
The AJAX response is a JSON object with:
price : formatted price string (respects the "Show taxed price" setting)
price_with_tax : formatted price with tax
price_without_tax : formatted price without tax
price_value : raw numeric price value
price_value_with_tax : raw numeric price with tax
formula : the formula object that was used
calculation : the full calculation metadata (same structure as $product->price_calculation on the server side)
Example: custom price display with breakdown:
// Override the default price update to add a breakdown
var originalRefresh = window.hikashop.refreshCalculatedPrice;
window.hikashop.refreshCalculatedPrice = function() {
// Call the original function first
var form = document.querySelector('form[name="hikashop_product_form"]');
if(!form) return;
var formData = window.Oby.getFormData(form, false);
var data = window.Oby.encodeFormData({formData: JSON.stringify(formData)});
window.hikashop.xRequest(calculationUrl, {mode:'POST', data:data}, function(xhr) {
var resp = Oby.evalJSON(xhr.responseText);
// Display the price
var html = resp.price;
// Add breakdown if calculation data is available
if(resp.calculation && resp.calculation.fields) {
html += '<ul>';
resp.calculation.fields.forEach(function(f) {
html += '<li>' + f.name + ': ' + f.raw_value + '</li>';
});
html += '</ul>';
}
document.getElementById('hikashop_product_price_with_options_main').innerHTML = html;
});
};
Changelog
2.4.0 on the 18th of March 2026
- Added
{currency_rate} tag: the exchange rate of the current display currency relative to the main currency. Use it to make fixed surcharges scale with currency, e.g. {price} + (10 * {currency_rate}) adds $10 in USD or 240 CZK when the rate is 24.
- Added
{currency_id} tag: the ID of the current display currency. Use it in conditions to apply different formulas per currency, e.g. condition {currency_id} == 2.
2.3.0 on the 18th of March 2026
- The plugin now exposes detailed calculation metadata on the product object ($product->price_calculation) including the original and resolved formula, price before/after calculation, tax info, and a breakdown of each field used with its raw value, resolved value, and whether tax was applied. This data is available in view overrides to display field contributions as separate lines in the cart or checkout.
- The AJAX calculation response now includes raw numeric price values (price_value and price_value_with_tax) and the full calculation metadata, making it easier to build custom frontend displays.
2.2.0 on the 16th of January 2026
- We've added automatic whitelist detection for non-price fields (quantities, IDs, counts) to prevent incorrect taxation in formulas.
- We've added :optional:VALUE modifier to allow formulas with optional custom fields that may not be set on all products.
- We've added :notax modifier to force taxation on fields when needed.
- We've added :withtax modifier to force taxation on whitelisted fields (quantities, IDs, counts) when needed.
- We've improved formula documentation with explanations of all available modifiers.
2.1.3 on the 2nd of December 2025
- The calculations plugin now takes into account the "Show taxed price" setting of the HikaShop configuration and it will display the calculated price based on this setting.
2.1.2 on the 4th of November 2025
- The calculations plugin now has a notes text area where you can write some text for each formula.
2.1.1 on the 29th of September 2025
- Checkbox custom item fields were not handled properly by the price calculations plugin.
2.1.0 on the 22th of September 2025
- The plugin can now work even if the product doesn't have any price already set for it.
- The plugin now returns the formula used to the javascript on the product page together with the calculated price. This way, the javascript can potentially act upon that formula.
- The plugin now supports providing a fixed number without tags in the formula field.
- We fixed an error with the calculation of the price on the product page in some cases with PHP 8.2 and higher.
- The plugin includes French, Japanese and Dutch translations.
2.0.0 on the 31st of March 2025
- The price calculations plugin now supports conditions on the formulas in order to allow for greater flexibility.
1.0.7 on the 16th of February 2024
- When several formulas would use the same custom item field and taxes would be calculated on the values of the custom item field, if the matching formula would not be the first one, the plugin would previously add the tax on the custom item field value once per formula before the matching formula.
1.0.6 on the 10th of January 2024
- When a custom item field is of the checkbox or multiple dropdown type, if the user selects several choices, the value of each choice selected will now be summed up to become the value of the field in the formula of the price calculations plugin. So basically, if someone selects option A with a value of 2, and option B with a value of 3, and the product has a base price of 10, if the formula is {price}+{customfield} the result will be 10+(2+3) = 15
1.0.5 on the 26th of October 2023
- On the product details page, the calculated price could be calculated with the values coming from the custom fields not taking into account the taxes even though it should be with taxes for products with variants in some cases.
1.0.4 on the 15th of September 2023
- On the product details page, the calculated price could be without taxes even though it should be with taxes for products with variants in some cases.
1.0.3 on the 23rd of august 2023
- The plugin didn't apply the formula properly on the product page when the {cart_product_quantity} tag was used and the quantity input of the product was hidden.
- We've added the boolval and empty functions support to the calculations plugin.
1.0.2 on the 11th of July 2023
- We've fixed a calculation issue on the product page in some cases.
1.0.1 on the 16th of September 2022
- The price calculations plugin now properly take into account the options selected on the product page for the calculated price display.
- We fixed an issue when having several products using the same formula in the cart.
1.0.0 on the 11th June 2022
- Initial release of the plugin