Support ACF Relationship field for order
under review
P
Paul Montalto
The relationship field is not compatible with Woocommerce orders.
There order list in the field do not have the order ID, only the Woocommerce status. This makes it impossible to differentiate an order from the other.
We only need to make sure the order number is passed so we can search for an order and add it to the relationship field
Iain Poulson
marked this post as
under review
Iain Poulson
Hi Paul Montalto, this can be achieved with a filter. I've added this to the docs here - https://www.advancedcustomfields.com/resources/acf-fields-relationship-result/#examples
add_filter('acf/fields/relationship/result', 'my_acf_fields_relationship_result_woocommerce_orders', 10, 4);
function my_acf_fields_relationship_result_woocommerce_orders( $text, $post, $field, $post_id ) {
if ( $post->post_type !== 'shop_order' ) {
return $text;
}
return str_replace( 'Order', 'Order ' . $post->ID, $text );
}