Skip Navigation

[Resolved] Formatting Money

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 0 replies, has 1 voice.

Last updated by Minesh 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2781679

I'm trying to format a number from a custom field as money. For example 1500 -> 1,500

I've almost managed, but the number showing isn't correct. It's from a totally different post.

I've followed the below links:
https://toolset.com/forums/topic/output-format-for-a-custom-field-number/
https://toolset.com/forums/topic/format-number/

This is where you can see it:
hidden link

#2781680

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me where exactly you added the custom shortcode and on what part of the problem URL you shared under what title.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2781708

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I changed the shortcode as given under:
=> hidden link

function format_my_number($atts) {
    $atts = shortcode_atts(
        array(
        'fee' => '',
        'symbol' => '',
    ), $atts );
	
    $fee = (float) $atts['fee'];
	
   
    return $atts['symbol'].''.number_format($fee);
}

add_shortcode('format-currency', 'format_my_number');

Can you please confirm it works as expected:
- hidden link

#2781711

Hi Minesh, thanks for your help but it is not working as it should. Now all the courses are €195. They shouldn't be.

#2781739

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - it seems there is issue how the theme is loading the template file or something else.

I need FTP/SFTP access details. Can you please send me.

I have set the next reply to private which means only you and I have access to it.

#2781786

I got it to work on the Courses page (hidden link) using the following shortcode

[format-currency field_slug="course-fee" symbol="€"]

#2781794

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems somehow the single pages have heavy caching on with your server.

What if you try to check with default theme for a moment and see if it works as expected.

#2781808

The site is built with Elementor. I would have to manually create a template for the courses to test.

At one point, the courses page was working with each course showing the correct price.

#2781818

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I understand but as I shared there is some issue due to theme or any other plugin you use. It it either caching or theme issue. To ensure its theme issue, you will have to run a test with another theme.

If it works with default theme then you will have to get in touch with your theme author.