• Resolved MoBlaise

    (@moblaise)


    Hi Konrad,
    First of all – great plugin, thank you!

    I have set up a pair of bidirectional post object fields on my custom post type (CPT) and on on the WooCommerce orders. The field shows up on the chekout page and is supposed to connect the order with the CPT.
    The field gets saved on the order page and is visible in the admin area. However, the field on the CPT does not get updated.

    If I try to update either field from admin it all works as expected.

    Do you have any idea how to fix this?

    Here is the code I’m using to update the field from the frontend:

    add_action('woocommerce_checkout_update_order_meta', 'checkout_fiat_update_order_meta');
    function checkout_fiat_update_order_meta( $order_id ) {
    			$field_name = 'fiat';
    			$field_value = $_POST['acf']['field_6388bf4231c86'];
         if ( ! empty( $field_value ) ) {
           	 	update_post_meta( $order_id, $field_name , $field_value );
        }}
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    When dealing with ACF/ACF Extended features programmatically, it is recommended to use native ACF functions such as get_field() update_field() etc…

    In your case, the issue is that you use the WordPress function update_post_meta() to update a meta value, so ACF/ACF Extended are not aware of that change.

    In order to update an ACF field value, I would recommend to use the native update_field() (see documentation) instead. This way, all ACF/ACF Extended logic are correctly triggered, including the ACFE Bidirectional Setting feature.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter MoBlaise

    (@moblaise)

    You’re a life saver!
    It works perfectly!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    I’m glad to hear it now works as expected!

    If you enjoy this plugin, and its support, feel free to submit a review. It always helps and it’s much appreciated 🙂

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bidirectional field not updated’ is closed to new replies.