Support

Account

Home Forums Front-end Issues ACF and Woocommerce Products

Solved

ACF and Woocommerce Products

  • Hi,

    Hoping someone can assist – I am trying to use the Advanced Custom Fields plugin together with the repeater add-on, with Woocommerce products.

    To begin with, I have setup two products, Product A and Product B as part of the Woocommerce plugin.

    Now, with the ACF plugin, I have created two field groups, Field Group A and Field Group B – both fields being of field type “Repeater”.

    Now based on the above setup and hoping it makes sense, I now need to attach custom Field Group A to Product A and custom Field Group B to Product B.

    I have attempted to do this within each of the field groups via the location rule(s), where I have specified:

    Post Type is equal to product

    But by doing this, it is placing both Field Group A and Field Group B to each of the Products, which is not want I want.

    In addition to the above location rule, I also need another rule to target the post-title or post-name but do not seem to have this available as a drop-down within the location rules.

    1) Can anyone pls assist as to how to place Field Group A to just Product A and the same for Field Group B to Product B?

    2) If I am not able to target each product, can people please suggest how I can access the Field Groups A or B based on the Product page I am on, that is, if I am on Product A and realise that both Field Group A and Field Group B are available to be, in the backend PHP, can I just target Field Group A alone?

    3) Is what I am trying to do above, even possible with ACFs together with Woocommerce Products?

    Any help would be great.

    Thanks.

  • Hi @softprinciples

    The location rules also include a ‘post’ => ‘specific post name’.

    Please use this to map the field group to a specific post (product).

    Thanks
    E

  • Thanks for the response Elliot but unfortunately selecting “post” does not give me access to the actual individual products themselve – these are not appearing.

    Are they suppose to Elliot b/c from what I can see, you are not classifying Woocommerce (individual) products as a post – is this correct?

    Selecting post in the location rules only displays actual posts within the “Post” menu option in WordPress and that’s it.

    At the moment within the Products section of Woocommerce, I have two products, Product A and Product B – it is these I am trying to access, inorder to place specific field groups against them.

    If I look within the wp_posts table, I can see my two products

    where post_type = 'product'

    what I need in addition are access to the columns post_name or post_title, as these will give me access to a specific product but I am not able to get to these via ACF location rules.

    Any further ideas/workarounds Elliot would be much appreciated as I only want specific custom field groups against a specific product, i.e. Product A.

    Thanks again.

  • Hi @softprinciples

    Thanks for the follow up. I just did some testing, and can confirm that there is a bug preventing the Woocommerce products from appearing.

    I have fixed the issue and pushed the fix to github. Please download the latest version, and let me know how you go.

    Thanks
    E

  • Hi @elliot,

    Thanks for coming back with a fix – I have downloaded and installed new version from your https://github.com/elliotcondon/acf and all looks great.

    I can now see a sub-heading of product with a list of the products items below it.

    Are you able to let me know what you changed if possible, in order to understand the change from a developer’s perspective (only if possible).

    BTW, when will this new version be available for production download from wordpress.org plugins?

    Thanks E and good job.

    S.

  • Hi @softprinciples

    You can see the diff here:
    https://github.com/elliotcondon/acf/commit/2da1e81deac10b739b5510127d923c509cdeca5d

    The next version should be released in a week or so

    Thanks
    E

  • Hi Elliot. I can see the post-type selection as “products” fine. But I’ll need to select the product category, too, to further narrow down the field display. However my product categories are not listed under post categories.

    Am I missing something, maybe?

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

The topic ‘ACF and Woocommerce Products’ is closed to new replies.