products_price vs final_price in orders_products

Ask the community for help and support.
Post Reply
Steek
Posts: 4
Joined: Mon Mar 01, 2021 2:51 pm

products_price vs final_price in orders_products

Post by Steek »

I have a problem with field ‘final_price’ in the table ’orders_products’.
There are 2 price fields in this table: products_price (shows the price as 4.1322) and final_price (showing the price as 4.000). Every decimal is set to 0.
Both fields have the same structure in de database, so I guess the problem is not in de database but somewhere in de code.
I made some minor (documented) core-code changes and changes in the database (extra fields in products and products_description).
I guess it has to do with a format of the ‘final_price’ value before it is updated in the database, but I just can’t find the place where this is done.
Can anyone point me in the right direction or give me a tip to fix this?
Thanks in advance.
Steek
Posts: 4
Joined: Mon Mar 01, 2021 2:51 pm

Re: products_price vs final_price in orders_products

Post by Steek »

Unfortunately, I didn't have time to continue with the site, but in the meantime started again for a while. Unfortunately I haven't been able to solve the problem yet.
The website in question has 3 languages. I tested with the purchase of the same product in all three different languages, everything with the same shipping, the same address, country (and therefore VAT rules) etc.
With the English language the order goes well and both fields are the same in the database. Things go wrong with Dutch and German. There the products_price and final_price are different. The result is that the invoices in these languages ​​do not show the correct amounts and I have to manually change the fields in the database to get the invoice right.
Can someone tell me why filling an amount in the database depends on the language of the website? Can someone help me to find the solution (point me in de right direction)?
Version is CE Phoenix v1.0.8.18, PHJP 7.4.9 (Zend 3.4.0), Addons: Ultimate_SEO_Urls v3.0.5, ZipurFavoriteCountries, Store_Mode_1.4.4, Maths Recaptcha and the language packs for Dutch and German.
beerbee
VIP Member
VIP Member
Posts: 46
Joined: Mon Oct 26, 2020 4:56 pm
Has thanked: 2 times
Been thanked: 3 times

Re: products_price vs final_price in orders_products

Post by beerbee »

Hi,
I think this is a result of LC_ALL in the main language files for example: english.php

Code: Select all

@setlocale(LC_ALL, ['en_US.UTF-8', 'en_US.UTF8', 'enu_usa']);
where there is no problem.

But LC_ALL also sets LC_MONETARY to [mon_decimal_point] => ,
for many languages. That is where the problem lies.
https://www.php.net/manual/en/function.setlocale.php

So I set it only for time in my german.php language file:

Code: Select all

@setlocale(LC_TIME, ['de_DE.UTF-8', 'de_DE.UTF8', 'deu_deu']);
Got me rid of the problem.

Kind regards
Christoph
Steek
Posts: 4
Joined: Mon Mar 01, 2021 2:51 pm

Re: products_price vs final_price in orders_products

Post by Steek »

Hi Christoph,

I cannot thank you enough for this solution. Made the adjustment in both language files and it works great.

Kind regards
Harald
leifi
Posts: 3
Joined: Tue Sep 06, 2022 7:24 pm

Re: products_price vs final_price in orders_products

Post by leifi »

final_price - german, the problem starts with install Addon Ultimative SEO Urls, by using only one language german.
Thanks to Harald (dankjewell) for take me here and thank you very much Christoph for the fix
Post Reply