use text instead of price when item price equals zero

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #8848

    Olly
    Admin & Mod

    example:
    as of v2.11.8.6 you can add this to your themes functions.php if you would like to display “free” for example if price would otherwise be displayed as 0.00 (note to self: perhaps make that an option at some point)

    
    add_filter('wppizza_filter_output_format_price','my_function');
    function my_function($priceformatted){
    	/*get rid of any formatting first and cast to  integer*/
    	$price=(int)str_replace(array(',','.'),'',$priceformatted);
    	/*if zero, display some text instead*/
    	if($price==0){
    		$priceformatted=__('free','wppizza');/*set this to whatever text you need to be displayed*/
    	}
    	
    	return $priceformatted;	
    }
    

    PS: not 100% tested, but should work. if you have any issues, let me know.

Viewing 1 post (of 1 total)

The topic ‘use text instead of price when item price equals zero’ is closed to new replies.