• Resolved avandelaak

    (@avandelaak)


    Hi, I have used the thermometer to show a dynamic raised value via a Molly form. The format of the raised value is incorrect. It should be EUR 7565,00 and is showing 7.57 instead.

    I adapted the file: therm_shortcode.php with this code from another topic:

    //raised value
    	if ($atts['raised'] == '' && !empty($options['raised_string'])){
    	    $thermProperties['raised'] = $options['raised_string'];
    	}
    	else{
    		if (!is_numeric(str_replace(",", ".", $atts['raised']))) {
    			$shortcode = "[".strval($atts['raised'])."]";
    			$atts['raised'] = do_shortcode( $shortcode);
    		}
    	    $thermProperties['raised'] = str_replace(",","",strval($atts['raised']));
    	}

    Still the same issue. How can I get the value showed correctly?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author rhewlif

    (@henryp)

    Hi,
    I think the problem is I have not taken into account the use of commas for a decimal point when parsing a shortcode, which is adding to the confusion.

    Since you seem comfortable to change the plugin code, then to fix this quickly you can change line 121 in therm_shortcode.php to
    $thermProperties['raised'] = str_replace(',', '.', str_replace('.', '', strval($atts['raised'])));

    and line 57 in therm_svg.php to:
    $raisedValue = ($thermProperties['trailing'] == 'true') ? number_format($raisedTotal,$decimals,',',$thermProperties['sep']).$currency : $currency.number_format($raisedTotal,$decimals,',',$thermProperties['sep']);

    I am also presuming on the settings page or in the thermometer shortcode you also have set the parameters sep=. and decimals=2.

    I’ll prioritise this fix more permanently for the next plugin update.
    Cheers

    Thread Starter avandelaak

    (@avandelaak)

    This works! Many thanks!

    Plugin Author rhewlif

    (@henryp)

    I’ve just pushed version 2.1.1 which should help with this issue. Just use the new parameter ‘decsep’

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Raised value via shortcode’ is closed to new replies.