Home Forums General Issues how to use ACF Post types to refine woocommerce product searches in Avada


how to use ACF Post types to refine woocommerce product searches in Avada

  • Hi I have a website with woocommerce in Avada with ACF pro.

    I have 3 custom fields set up and added to woocommerce products, these fields show in the add/edit products page, and show on the woocommerce product page. This part is working perfectly.

    I have a form set up which posts the query using the method GET to /?s=
    in the form is a hidden field with the value post_type=product
    in the form is a drop down menu withe the value product_cat in the Field Name and a list of the category names and slugs in the options menu.

    So far this part works fine, I can search for anything, and refine the search by product category.

    The part I need help with is include the ACF custom fields in the form to refine the search further.

    What values should I use for the three ACF custom fields?

    For example the first custom field set up in ACF is a Post Type called Authors (the plural label is Authors, the singular label is Authors, and the Post type key is authorname, under taxonomies is Product Visibility)

    Under the main Taxonomies tax on the left there is nothing.

    How do I go about adding this Post Type as another refining factor in the search form.
    I can add a text field but what should I set as the Field Name?

  • You cannot search one post type by content contained in another post type. The only thing that ACF stores for a Post Object field or Relationship field is the post ID or array of post IDs for the post or posts that are selected. So the only thing you can search by it the ID of the post. How the query would need to be build would depend on what type of field you are using and whether or not is stores a single value or an array of values.

    This is a guide that shows how to search based on an array in a relationship field

  • I didnt understand your reply.

    I can already search any of those advanced custom fields set up the the ACF Pro plugin in the main search on wordpress. This was achieved by setting up the fields and setting the taxonomy as Product Visibility and then installing the plugin: “ACF: Better Search”

    So in one of the ACF fields I have dates, if I enter a date from one of those fields in the main search it will find the product that has that date in the ACF field.

    I now wish to refine that search to be able to check for searches that also match the search keyword plus the advance custom fields that I set up.

    Avada Support told me that it was possible with your plugin:
    “Every search parameter like category/tags has to be a taxonomy. For this to work, you will need to add custom taxonomies via a plugin like ACF”

    But they dont offer support in how to do it, which is why im asking here

  • I can’t tell you how to use “ACF: Better Search”. This is a plugin by another developer and I do not use it.

    What I do know is that you cannot alter the “s” parameter in the WP search to include searching a post based on a taxonomy.

    You would need to have a separate field that listed the terms in the taxonomy where the value submitted is the term_id for each term. Then you would need to alter the query done during the search to add a tax_query.

  • Sorry you are mistaken, in Avada you can do exactly that and I have and it is working perfectly. I was just seeking support from the company who provide ACF Pro on how to further refine the search.

    Thank you for your opinions and your time, but im looking for support from ACF themselves.
    (Or someone who has experience of this and knows how to do it.)

  • No one from the ACF “team” monitors these forums. If you want to talk to support then you need to contact them directly with this form or open a ticket on your account.

    But as I said, you cannot refine a query by data in another post. The only thing available for searching a post would be the post ID of the other post saved in the field. This is what I understand from your OP.

  • You are wrong, I have built several search forms that do exactly that and work perfectly, they allow you to search for products and to refine by product categories, and by product tags, and if you add the other plugin I mentioned , it also allows you to search by acf custom fields added to the products.

    if you are interested in learning how it is done, check out the video on youtube called:

    “Create an Advanced Search Form With Avada Forms”

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

You must be logged in to reply to this topic.