Does anyone know how to write a customer bi-directional relationship query?
I want to query associated reviews for items in my cart on the checkout page. This is not working
$product_ids = [];
foreach ( WC()->cart->get_cart() as $item ) {
$product_ids[] = $item['product_id'];
}
if ( empty( $product_ids ) ) {
return null;
}
return new WP_Query([
'post_type' => 'review',
'posts_per_page' => -1,
'meta_query' => [
[
'key' => 'reviews_to_products', // ACF relationship field
'value' => array_map('strval', $product_ids),
'compare' => 'IN',
]
]
]);