AbanteCart Community

General Topics => General Discussion => Topic started by: OneMore on February 23, 2024, 12:45:58 PM

Title: Is .– instead of .00 commonly used worldwide for displaying round prices?
Post by: OneMore on February 23, 2024, 12:45:58 PM
In my country, it is common not showing cents for round prices, and replacing them with a dot and a dash, like 59.– instead of 59.00 .

Is this way of displaying prices is commonly understood worldwide or only in my country?

If known at international level, I will implement it in the templates used by my shop with code like:
Code: [Select]
<?php echo str_replace('.00','.&ndash;',$price); ?>
Title: Re: Is .– instead of .00 commonly used worldwide for displaying round prices?
Post by: Nuno Neff on February 24, 2024, 02:33:19 PM
Portugal  uses 55.00€

Although I think it looks ugly, it should be 55€
Title: Re: Is .– instead of .00 commonly used worldwide for displaying round prices?
Post by: llegrand on February 24, 2024, 08:30:53 PM
You can set the number of decimal places showing within the System > Settings> localization > currencies
https://abantecart.atlassian.net/wiki/spaces/AD/pages/15270043/Add+or+Edit+Currency (https://abantecart.atlassian.net/wiki/spaces/AD/pages/15270043/Add+or+Edit+Currency)
Title: Re: Is .– instead of .00 commonly used worldwide for displaying round prices?
Post by: OneMore on February 25, 2024, 06:44:46 AM
Thank you Nuno.

So here's my quick implementation of a price beautifier.

A) Removing decimals in prices on PRODUCT PAGES
In 'storefront/view/default/template/pages/product/product.tpl', after line 94 (i.e. after the "if ($display_price){}" sandwich), add:
Code: [Select]
// Remove decimals for prices ending with ".00", for both special and normal prices.
           if (strpos($special,'CHF')) {
                $special=  str_replace('.00','.&ndash;',$special);
              } else {
                $special = str_replace('.00','',$special);
              }
          if (strpos($price,'CHF')) {
                $price=  str_replace('.00','.&ndash;',$price);
              } else {
                $price = str_replace('.00','',$price);
              }

How does it work
If the product price contains "CHF" (Swiss Franc), it will replace ".00" by ".–".
For all other currencies, it will replace ".00" by nothing.
This assumes you are only using the dot as separator for the trailing decimals".


Added 2024/02/27
B) Removing decimals in prices for FEATURED PRODUCTS
In 'storefront/view/default/template/blocks/product_list.tpl', after line 70:
1. Add
Code: [Select]
$special = $product['special'];
$price = $product['price'];
2. Copy and paste the aforementioned code that removes the decimals.
3. In the <div class="price"> ... </div> sandwich right after, replace echoed instances of $product['special'] by $special, and $product['price'] by $price.



Added 2024/02/27
C) Removing decimals in prices of products on CATEGORY PAGES
In 'storefront/view/default/template/pages/product/product_listing.tpl', after line 63, do the same as above for featured products.



Added 2024/02/27
Requirements
For the code above to work you need the decimal delimitor being the dot and not the comma.
Else, you would need to adapt the code.
To set the decimal delimitor:

Suggestion for a better implementation
A better implementation would be creating an method, or modifying existing method, so that the same code can be re-used for all price formatting.
Another improvement would be adapting the code to deal with the effective decimal delimitor.


@llegrand: Sorry, but my question was about if the ".–" was international or used only in some countries like Switzerland.
Furthermore, setting the decimals to 0 is not what I wanted to do : 99.95 CHF must remain unchanged. Only 99.00 CHF should be displayed as 99.– CHF.
Title: Re: Is .– instead of .00 commonly used worldwide for displaying round prices?
Post by: Burlesque on March 06, 2024, 03:22:29 AM
The practice of omitting cents and using a dash to represent rounded prices is not a universal standard. It varies across different regions and cultures. In many countries, prices are commonly displayed with cents, and the use of a dash may not be a familiar convention.

If your target audience is primarily local and accustomed to this practice, implementing it in your templates could make sense for a more familiar and user-friendly experience. However, if your shop caters to an international audience, it's advisable to display prices in a way that aligns with broader expectations, which typically include showing cents.

Always consider the preferences and expectations of your specific audience to enhance their understanding and usability of your e-commerce platform.