Home › Forums › Calendar Products › Community Events › Format for pricing display
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by
George.
-
AuthorPosts
-
March 18, 2016 at 2:34 am #1090813
Per
ParticipantHi
I am wondering if someone can advise me as to how to correct the formatting for price display on single events and in the calendar list view
The price that is displayed is incorrectly formatted, for example; it currently displays prices as “”” kr2700 “”” but the correct format should be “”” kr 2,700.- “”” (Norwegian kroner).See this page and this page for examples (class=”tribe-events-event-cost” and class=”tribe-events-cost”)
Regards
March 18, 2016 at 7:26 am #1090940George
ParticipantHey @Per,
Thank you for reaching out.
Have you changed the “default currency symbol” in your Events Settings to be kr? Here’s a screenshot of the option I am referring to:
That is the only “out-of-the-box” currency control we have.
If you’ve done that, and have the current issues, it seems like the problem is this:
1. The format is kr2700, no spaces between kr and the digits.
2. It SHOULD be kr 2700, with a space between kr and digits. Correct?
3. Next, can you clarify the .- symbols when you write kr 2,700.- ? Are you saying that two zeroes should be added there, like kr 2,700.00? Are you saying that literally the period and the dash are required?
4. Finally, can you clarify if the period and dash are truly required? Or is this just a personal preference of yours? For example, with US Currency it’s generally accurate for price tags in stores to list the .00 at the end of a whole-number price, e.g. $50.00. But in any context it is fine to just write $50, because the .00 is assumed.
Let me know what you think in response to each of my comments and questions above—this will help a lot, and @Per, while there are not any “out-of-the-box” features to add the special formatting you desire here, I will try to write a custom code snippet that makes the prices have the specific format.
Thank you!
GeorgeMarch 18, 2016 at 8:14 am #1090978Per
ParticipantHi George
Thankyou for your responce.
I actually made a mistake in typing the format in my first post 🙂
Yes, I have tried adding the space in general settings(Default currency symbol)( “”kr “” ) but it gets removed.
1. Correct, the format is currently kr2700
2. Correct, it SHOULD be kr 2700
3. The correct currency format for Norwegian is kr 2.700,- or kr 2.700,00 (kr #.###,##)It is normal to have the dash after instead of the two decimals
4. They aren’t truly required but they help with readability. As a minimum I would need to have the space between the kr and the number (kr ###). Also it would be nice to get a fix for this as we plan on using your plugins for a lot of our sites
March 19, 2016 at 1:16 pm #1091447George
ParticipantHey @Per,
Thanks for clarifying things and for your patience here. I’ve gone ahead and written some code that should at least handle the spacing between the kr and the actual currency.
To test this, try adding the following code to your theme’s functions.php file:
add_filter( 'tribe_get_cost', 'tribe_filter_cost_for_kr', 20, 3 );function tribe_filter_cost_for_kr( $cost, $post_id, $with_currency_symbol ) {
if ( ! empty( $cost ) && 'Free' !== $cost ) {
$cost = sprintf( 'kr %s', str_replace( 'kr', '', $cost ) );
}return $cost;
}
Cheers!
GeorgeMarch 21, 2016 at 5:45 am #1091710Per
ParticipantHi George
Thanks for your help.
The code you gave me didn’t solve the problem; it added “kr ” to the string that was already there (kr kr2700) so I modified it a bit and now it is displaying with a space.
Here is the code after I modified it 😉
add_filter( 'tribe_get_cost', 'tribe_filter_cost_for_kr', 20, 3 ); function tribe_filter_cost_for_kr( $cost, $post_id, $with_currency_symbol ) { if ( ! empty( $cost ) && 'Free' !== $cost ) { $cost = sprintf( '%s', str_ireplace( 'kr', 'kr ', $cost ) ); } return $cost; }Thank you for the help
Regards
March 21, 2016 at 2:32 pm #1092038George
ParticipantAwesome—best of luck with your site!
-
AuthorPosts
- The topic ‘Format for pricing display’ is closed to new replies.

