Support

Home Forums Event Espresso Premium Remove decimals from price in the table view

Remove decimals from price in the table view

Posted: December 3, 2015 at 10:33 am


Oguzhan Altun

December 3, 2015 at 10:33 am

Hello,

In the table view for my events, the prices show with 2 decimals even though I have set the setting to zero. I think it might to do with the code in the table, which is as follows:

// grab first ticket from array
		$ticket = array_shift( $tickets );
		$ticket_price = $ticket instanceof EE_Ticket ? sprintf("%0.2f",$ticket->ticket_price()) . '<span class="currency-code"> (CHF)</span>' : '';
		$ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : '';
		$tickets_price_free_check = $ticket_price_data_value == 0 ? __('Free','event_espresso') : $ticket_price;

What do I have to change here to remove the decimals?


Tony

  • Support Staff

December 4, 2015 at 3:20 am

Hi there,

This is due to custom coding within your events table template and is due to this line:

sprintf("%0.2f",$ticket->ticket_price())

“%0.2f” is forcing the value to be returned with 2 decimal places.

You need to remove the sprintf function and just use $ticket->ticket_price()

Note that we can not provide support for custom coding, if you need further assistance with this you need to contact the author of that code.


Oguzhan Altun

December 4, 2015 at 3:33 am

Excellent, this worked. The code was from another very helpful EE4 support team member. Thank you.

The support post ‘Remove decimals from price in the table view’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso