Support

Account

Home Forums ACF PRO Use update_field() in wp-admin to update a few ACF field values on posts

Helping

Use update_field() in wp-admin to update a few ACF field values on posts

  • I have created a CPT to apply price amendments to groups of WooCommerce products, based on the supplier taxonomy that has been selected (the supplier is set up as a standard taxonomy field on each individual product page, so I’m presuming i’ll be able to query products based on it because it was also set up to be queryable by WP).

    I’ve set up the price amendment CPT as follows (ignore the adjusted products section – it’s just a mockup of what I hope to eventually have and is not functional, not a necessary feature):

    CPT setup

    So the process would be:

    – Select a supplier to issue a price increase/decrease to across the products with that supplier selected
    – Select if it’s a price increase or decrease
    – Type in the percentage to base the increase/decrease on

    Once those fields have been filled in I’ll have a preview button will load in via ajax the list of affected products, along with the old price / new price.

    What I want to happen is upon publishing this price amendment I want to update fields I need to within each product that matches the selected supplier chosen above (could be 3 products or could be 200 – it varies). Is there a way to do this upon clicking “Publish” by hooking into the save post function and using update_field() to update the relevant price fields? (I’ve got both the standard Woo price field and some custom ones within a custom variations plugin I’ve built with ACF).

    Any pointers in the right direction would be appreciated.

    Thanks,
    Matt

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

The topic ‘Use update_field() in wp-admin to update a few ACF field values on posts’ is closed to new replies.