filter price format

Viewing 1 post (of 1 total)
  • Author
  • #18395

    Admin & Mod

    to filter the output of prices in some shape or form other than whats already available from wppizza->layout, you can use the following filter in your theme’s functions.php

    add_filter('wppizza_filter_output_format_price', 'my_prefix_price_format');
    function my_prefix_price_format($price){
    	if - for example - you do not want to display trailing zeros , you could simple do the below
    	/* if your language uses period as decimal separator */
    	$price = floatval(str_replace(',', '.', str_replace(',', '', $price)));
    	/* if your language uses commas as decimal separator, use the below instead */
    	//$price = floatval(str_replace(',', '.', str_replace('.', '', $price)));
    		you can go one step further and format thousand separators again.
    		just uncomment the below
    	//$format = explode('.', $price);
    	//$price = number_format_i18n( $price, empty($format[1]) ? 0 : strlen($format[1]) );
    return $price;
Viewing 1 post (of 1 total)

The topic ‘filter price format’ is closed to new replies.