Support

Account

Home Forums Backend Issues (wp-admin) how to recalculate the value of the coefficient field automatically?

Solving

how to recalculate the value of the coefficient field automatically?

  • Hi.
    I have a price field (number) in custom post type.
    How to automatically update the value in all posts by the formula price*coefficient. Coefficient I set on the options page

  • The only way to update the value in all posts is to do a query to get all of the posts and loop over them and set the new value for each post in the loop.

    Depending on the number of posts you have this could potentially just time out and fail.

    Is it necessary to actually store the calculated value? Why are you storing a calculated value? Not saying you don’t need to store the value, I just want to understand why it’s needed and that might provide ideas on how to work around the limits.

  • This is required for a directory where there are 2 currencies. Currency is calculated by the exchange rate. The site has a filter for one of the currencies, but when creating a post, the value is set in different currencies

  • Do you do any kind of a search or filtering based on the calculated value?

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘how to recalculate the value of the coefficient field automatically?’ is closed to new replies.