Skip Navigation

[Gelöst] calculation help needed : sqft to sqm , price per sqft

This support ticket is created vor 7 Jahren, 7 Monaten. There's a good chance that you are reading advice that it now obsolete.

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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 15 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Akhil vor 7 Jahren, 7 Monaten.

Assistiert von: Minesh.

Author
Artikel
#504119

Hi, i am creating layout now and really fun.
[types field='p-size' format='FIELD_NAME: FIELD_VALUE'][/types] exp output : 2500 sqft

I need some help with

1. output as "2,500 sqft "

2.changing sqft to sqm .
i just need to divide the raw value with 10.7639 and round up to integer value.

3. Price PSF = Price / Size and round up to integer.

I tried to search for known solution but none found.

Cheers.

#504189

i understand that i need to create a short code function for this .

i have many fields that need the thousand separators, do i need to create the function for all custom fields?

#504258

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Yes - you need to use custom shortcode for such conversion but where exactly you want to display this conversion.

For thousands separator, you should build a shortcode and user PHP number_format function.
For example:

add_shortcode('number-format', 'number_format_shortcode');
function number_format_shortcode($atts, $content = "") {
 return number_format(wpv_do_shortcode($content),2, '.', ',');
}

And you can call shortcode like:

[number-format][types field="price"][/types][/number-format]
#504260

Hi Minesh !

I need to output this to layout for now . for my template and archive .
Could you guide me on the sample code for calculation please. I only see those calc under if conditions.nothing on direct output to layouts.

thanks

#504266

Minesh
Supporter

Sprachen: Englisch (English )

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

Could you please share problem URLs and few screenshot where exactly you want to display calculation and which calculation should display at which part with your exact needs.

1)
Please share problem URL.

2)
*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

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

#504271

Hi Minesh,

there is no problem on the site. i just need help with the codes.

I have this field: [types field='p-size' format='FIELD_NAME: FIELD_VALUE'][/types] the sample output is : 2,500 . I just need a code to do a math operation on this value . It is to divide the 2,500 with 10.7639 . and i need to display the result.

I'm still on localhost development stage. thanks

#504273

Hi minesh,

the code you have output 2,500.00 how do i make it to 2,500 only please.

function number_format_shortcode($atts, $content = "") {
 return number_format(wpv_do_shortcode($content),2, '.', ',');
}
add_shortcode('number-format', 'number_format_shortcode');
#504276

OK i play around and found it , hope its the right one.

return number_format(wpv_do_shortcode($content),0, '.', ',');
#504285

Minesh
Supporter

Sprachen: Englisch (English )

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

For number format:

function number_format_shortcode($atts, $content = "") {
$x = number_format(wpv_do_shortcode($content),2, '.', ',');
$x = explode(".",$x);
 return $x[0];
}
add_shortcode('number-format', 'number_format_shortcode');

I have this field: [types field='p-size' format='FIELD_NAME: FIELD_VALUE'][/types] the sample output is : 2,500 . I just need a code to do a math operation on this value . It is to divide the 2,500 with 10.7639 . and i need to display the result.

function func_custom_conversion($atts, $content = "") {
$x = wpv_do_shortcode($content);
$x = $x/10.7639 ;
 return intval($x);
}
add_shortcode('custom_conversion', 'func_custom_conversion');

And call above shortcode as:

[custom_conversion] [types field='p-size'][/types][/custom_conversion]
#504317

Awesome !
thank you Minesh !

Just one simple question.
i cant call the field name into this code?

format='FIELD NAME : FIELD_VALUE'
#504320

Minesh
Supporter

Sprachen: Englisch (English )

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

No - as the shortcode is coded to do calculation - we need only numeric value so we do not need field name there. Outside the calculation shortcode you can use it if you want.

#504324

Awesome ! Thank you once again !

#504332

Sorry Minesh , we forgot about the psf price code :

3. Price PSF = field-Price /(divide by ) field-Size and the result to output and round up to integer.

thanks!

#504334

Minesh
Supporter

Sprachen: Englisch (English )

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

As per our support policy - we entertain only one question per ticket. Could you please kindly open a new ticket for your each new question.

This will help other users searching on the forum. Thank you for understanding.

#504337

OK. will do that.