Skip Navigation

[Resolved] price per sqft

This support ticket is created 7 years, 6 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 7 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#504345

Hi, i have two field

1. field-price
2. field-size

i need to calculate field price /(divide) field size and round up to integer .

How do we take 2 custom field and do math operations?

#504423

Hello,

Unfortunately we do not currently offer a way to perform mathematical operations on custom field values within Views. This must be accomplished with custom code, perhaps as a shortcode that can perform calculations on multiple values, or as JavaScript that performs calculations on the front-end of your site.

Here is a link to the WordPress documentation on shortcodes:
http://codex.wordpress.org/Function_Reference/add_shortcode

If you need professional help with this code, you can contact one of our certified partner contractors. Here is the list of our contractors:
https://toolset.com/consultant/

#504429

Hi Christian, thanks for the reply.

i know little bit of coding, when you say
" shortcode that can perform calculations on multiple values "
is exactly what im looking for. Could you provide a simple sample code how this can be calculated and i could study from there ?

how do i call the field value to template functions ? that's something new.

#504509

Hi, you can find a few math examples to get you started in these other forum posts:
https://toolset.com/forums/topic/mathematical-operations-with-number-custom-field/
https://toolset.com/forums/topic/how-to-display-calculated-field/
https://toolset.com/forums/topic/calculating-with-a-custom-field-and-a-woocommerce-field/

Here's a document that shows how you can use the values of a custom field in PHP. Click "More +" to reveal information about each field type:
https://toolset.com/documentation/customizing-sites-using-php/functions/

#504661

Hi, thanks for the sample links.
But i notice most of them contain wpv-loops .
Can the code be used at layout as well ?

#504829

Hi -
Yes, you can use a shortcode in a Layout. As long as you have access to the information you need (the values you want to use), and can pass that information into the shortcode (using a shortcode attribute), you can use that shortcode without a loop.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.