I want to add a complex filtering when getting my products.
- I have products where some of them are linked to a custom post type.
- This custom post type has a repeater field.
- Depending on a cookie, I should only get products that have that value in this repeater field
I know I can use:
add_filter( 'pre_get_posts', 'fwp_archive_per_page' );
I know i can set extra meta query like this:
$query->set( 'meta_query', array( 'relation' => 'AND', array( 'key' => 'xxx', 'value' => 'xxx' ) ));
But this is more complex as I should do a query on every product ID to check if the value exists in the repeater field from the related custom post type.
Anyone has a clue how to do this?
Or is there another way around to handle this?