Home › Forums › General Issues › Calculate a field using price and acf value › Reply To: Calculate a field using price and acf value
Update:
I was able to update the price per tablet by using the following code:
function wc_update_price_per_unit($post_id) {
$value= get_field('_price')/get_field('number_of_unit');//use _regular_price to get regular woocommerce price
$field_name = "price_per_unit";
update_field($field_name,$value,$post_id);
}
add_action('save_post','wc_update_price_per_unit');
The price_per_tablet value gets populated when saving the post. How can I see changes in the price_per_unit field before saving or updating the post.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.