[Skip to main content](#vessel-content)

#   Problem with calculation of product price by "decimal" length

##

- **[yanliom](/forum/user/45218-yanliom "View yanliom's Profile")**
- [![yanliom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/45218-yanliom "View yanliom's Profile") Topic Author
- [ Offline](/forum/user/45218-yanliom)

Less More

- Posts: 66
- Thank you received: 1
-
-

10 months 3 weeks ago [\#369772](#369772) by [yanliom](/forum/user/45218-yanliom "View yanliom's Profile")  *[Problem with calculation of product price by "decimal" length](/forum/26-product-category-display/909979-problem-with-calculation-of-product-price-by-decimal-length#369772 "-- url of the page with the problem -- :   www.ravopleko.gr  -- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.1 -- PHP version -- : 8.3  Hello,  I'm using your solution for calculating product price by length.  See topics: -https://www.hikashop.com/forum/product-category-display/898379-calculate-product-price-by-length.html -https://www.hikashop.com/forum/product-category-display/898421-decimal-calculate-product-price-by-length.html  But at the cart the price is calculated wrong.  Please see the attached screenshot were I'm testing various possibilities (I removed any restrictions for testing purposes).")* was created by *[yanliom](/forum/user/45218-yanliom "View yanliom's Profile")*

-- url of the page with the problem -- : [ www.ravopleko.gr](https://www.ravopleko.gr)
-- HikaShop version -- : 6.1.1
-- Joomla version -- : 5.4.1
-- PHP version -- : 8.3

Hello,

I'm using your solution for calculating product price by length.

See topics:
-https://www.hikashop.com/forum/product-category-display/898379-calculate-product-price-by-length.html
-https://www.hikashop.com/forum/product-category-display/898421-decimal-calculate-product-price-by-length.html

But at the cart the price is calculated wrong.

Please see the attached screenshot were I'm testing various possibilities (I removed any restrictions for testing purposes).

- [ ![2025-12-18145719.png](/forum/attachment/61061) ](/forum/attachment/61061 "...2-18145719.png") [ ](/forum/attachment/61061?download=1 "...2-18145719.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDk5NzktcHJvYmxlbS13aXRoLWNhbGN1bGF0aW9uLW9mLXByb2R1Y3QtcHJpY2UtYnktZGVjaW1hbC1sZW5ndGg/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14296
-
-

10 months 3 weeks ago [\#369773](#369773) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Problem with calculation of product price by "decimal" length](/forum/26-product-category-display/909979-problem-with-calculation-of-product-price-by-decimal-length#369773 "-- url of the page with the problem -- :   www.ravopleko.gr  -- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.1 -- PHP version -- : 8.3  Hello,  I'm using your solution for calculating product price by length.  See topics: -https://www.hikashop.com/forum/product-category-display/898379-calculate-product-price-by-length.html -https://www.hikashop.com/forum/product-category-display/898421-decimal-calculate-product-price-by-length.html  But at the cart the price is calculated wrong.  Please see the attached screenshot were I'm testing various possibilities (I removed any restrictions for testing purposes).")*

Hi,

I suppose you're using the plugin [ www.hikashop.com/marketplace/product/221...quantity-plugin.html](https://www.hikashop.com/marketplace/product/221-shopcustom-quantity-plugin.html)
So, the probably is probably with your custom item field. The column name of the custom field must be exactly "ordered_length". Otherwise, it will be ignored by the plugin.
Alternatively, you can use the price calculations plugin:
[ www.hikashop.com/marketplace/product/148...ce-calculations.html](https://www.hikashop.com/marketplace/product/148-price-calculations.html)
It has many advantages over the plugin you're using:
- you can have different fields for different products
- you can enter complex calculation formulas, not just price * value, and you can combine the value from different fields if necessary
- the plugin directly displays a "calculated price" on the product page when a field value is changed.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDk5NzktcHJvYmxlbS13aXRoLWNhbGN1bGF0aW9uLW9mLXByb2R1Y3QtcHJpY2UtYnktZGVjaW1hbC1sZW5ndGg/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[yanliom](/forum/user/45218-yanliom "View yanliom's Profile")**
- [![yanliom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/45218-yanliom "View yanliom's Profile") Topic Author
- [ Offline](/forum/user/45218-yanliom)

Less More

- Posts: 66
- Thank you received: 1
-
-

4 months 4 weeks ago -  4 months 4 weeks ago [\#372226](#372226) by [yanliom](/forum/user/45218-yanliom "View yanliom's Profile")  Replied by *[yanliom](/forum/user/45218-yanliom "View yanliom's Profile")* on topic *[Problem with calculation of product price by "decimal" length](/forum/26-product-category-display/909979-problem-with-calculation-of-product-price-by-decimal-length#372226 "-- url of the page with the problem -- :   www.ravopleko.gr  -- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.1 -- PHP version -- : 8.3  Hello,  I'm using your solution for calculating product price by length.  See topics: -https://www.hikashop.com/forum/product-category-display/898379-calculate-product-price-by-length.html -https://www.hikashop.com/forum/product-category-display/898421-decimal-calculate-product-price-by-length.html  But at the cart the price is calculated wrong.  Please see the attached screenshot were I'm testing various possibilities (I removed any restrictions for testing purposes).")*

Hello,

you have to provide an updated version of the plugin:
[ www.hikashop.com/marketplace/product/221...quantity-plugin.html](https://www.hikashop.com/marketplace/product/221-shopcustom-quantity-plugin.html)

I changed the code so that it works with the new Hikashop versions.

I don't know if it is 100% correct.

Best,
Yannis
Code:

&lt;?php jimport('joomla.plugin.plugin'); class plgSystemCustom_quantity extends JPlugin{ } if(!function_exists('fid_custom_quantity_normalize_length')) { function fid_custom_quantity_normalize_length($value) { $value = trim((string) $value); $value = str_replace(',', '.', $value); return (float) $value; } } if(!function_exists('hikashop_product_price_for_quantity_in_cart') &amp;&amp; !function_exists('hikashop_product_price_for_quantity_in_order')) { function hikashop_product_price_for_quantity_in_cart(&amp;$product){ $currencyClass = hikashop_get('class.currency'); $quantity = @$product-&gt;cart_product_quantity; $ordered_length = 1; if(!empty($product-&gt;ordered_length)){ $ordered_length = fid_custom_quantity_normalize_length($product-&gt;ordered_length); } $currencyClass-&gt;quantityPrices($product-&gt;prices, $quantity, $product-&gt;cart_product_total_quantity); if($ordered_length &gt; 0 &amp;&amp; $ordered_length != 1 &amp;&amp; !empty($product-&gt;prices)) { foreach($product-&gt;prices as $k =&gt; $price) { if(isset($price-&gt;price_value)) { $product-&gt;prices[$k]-&gt;price_value = (float) $price-&gt;price_value * $ordered_length; } if(isset($price-&gt;price_value_with_tax)) { $product-&gt;prices[$k]-&gt;price_value_with_tax = (float) $price-&gt;price_value_with_tax * $ordered_length; } } } } function hikashop_product_price_for_quantity_in_order(&amp;$product){ $quantity = $product-&gt;order_product_quantity; if(!empty($product-&gt;ordered_length)){ $ordered_length = fid_custom_quantity_normalize_length($product-&gt;ordered_length); $quantity = $quantity * $ordered_length; } $product-&gt;order_product_total_price_no_vat = $product-&gt;order_product_price * $quantity; $product-&gt;order_product_total_price = ($product-&gt;order_product_price + $product-&gt;order_product_tax) * $quantity; } }

Last edit: 4 months 4 weeks ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDk5NzktcHJvYmxlbS13aXRoLWNhbGN1bGF0aW9uLW9mLXByb2R1Y3QtcHJpY2UtYnktZGVjaW1hbC1sZW5ndGg/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14296
-
-

4 months 4 weeks ago [\#372229](#372229) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Problem with calculation of product price by "decimal" length](/forum/26-product-category-display/909979-problem-with-calculation-of-product-price-by-decimal-length#372229 "-- url of the page with the problem -- :   www.ravopleko.gr  -- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.1 -- PHP version -- : 8.3  Hello,  I'm using your solution for calculating product price by length.  See topics: -https://www.hikashop.com/forum/product-category-display/898379-calculate-product-price-by-length.html -https://www.hikashop.com/forum/product-category-display/898421-decimal-calculate-product-price-by-length.html  But at the cart the price is calculated wrong.  Please see the attached screenshot were I'm testing various possibilities (I removed any restrictions for testing purposes).")*

Hi,

I've updated the plugin. Thanks for the feedback.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDk5NzktcHJvYmxlbS13aXRoLWNhbGN1bGF0aW9uLW9mLXByb2R1Y3QtcHJpY2UtYnktZGVjaW1hbC1sZW5ndGg/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.066 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
