Format for pricing display

Home Forums Calendar Products Community Events Format for pricing display

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1090813
    Per
    Participant

    Hi
    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

    #1090940
    George
    Participant

    Hey @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!
    George

    #1090978
    Per
    Participant

    Hi 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

    #1091447
    George
    Participant

    Hey @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!
    George

    #1091710
    Per
    Participant

    Hi 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

    #1092038
    George
    Participant

    Awesome—best of luck with your site!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Format for pricing display’ is closed to new replies.