10 Sep

ACF Chat Fridays: Supporting WooCommerce HPOS

By Mike Davey

ACF Chat Fridays are open office sessions, providing a forum for users and the dev team to come together to solve challenges, share feedback, and gain insights into the future of ACF. Sessions are typically held on the first Friday of every month.

The September 6th session of ACF Chat Fridays included a demo of a new capability coming in ACF 6.4: integrating ACF fields with WooCommerce’s High Performance Order System (HPOS).

Co-hosted by Iain Poulson, Matt Shaw, Phil Johnston, and Anthony Burchell.

Sign up for the next session →

ACF Chat Fridays Banner Image.

Session Recording

You can see the entire session in the player below, or catch the highlights in the session summary.

Session Summary

The latest session kicked off with a demo by Matt Shaw, showing how to use ACF with WooCommerce HPOS. This demo highlighted how ACF 6.4 will support the new custom database table introduced by WooCommerce HPOS.

During the demo, Matt demonstrated how to create a field group for WooCommerce orders and how ACF fields are displayed on the new order screen, which uses React. He explained that with HPOS enabled, orders are stored in a custom database table rather than the traditional post meta table, which should improve performance by reducing the load on the WordPress posts and post meta tables. The demo also showed that ACF fields can be updated and retrieved without additional configuration, thanks to WooCommerce’s backcompat features.

In addition to the demo, the team discussed the recent release of ACF 6.3.6, which included security fixes and other bug fixes. The full change logs are available in the release post.

The team also touched on other plans for ACF 6.4, including a significant refactor of how ACF stores and retrieves field values, potentially reducing the number of queries needed. This refactor will make it easier to add future integrations like the one with WooCommerce HPOS.

There was also a discussion on the “React-ification” of ACF fields, i.e., rebuilding them in React rather than PHP, with the goal of improving the editing experience within the block editor. This will likely start with the simpler fields, such as Text and Text Area, making them editable directly in the main block editor view. This transition will be phased to ensure that the flexibility and compatibility of ACF are maintained.

The session also addressed questions about using ACF with Full Site Editing (FSE) themes and the Block Bindings API.

Q&A

We’ve included some of the questions and answers from the latest session below. Minor edits have been made for clarity and style.

Q: Will ACF support custom fields in WooCommerce product variations?

A: While this is not currently being worked on, the flexibility introduced by HPOS makes it more feasible to prioritize this feature in the future. Product variations are stored differently, but the new approach to data storage could make it easier to support custom fields in product variations going forward.

Q: Are you “React-ifying” the fields themselves, or just the instance of certain fields?

A: We are doing both—rebuilding fields in React for use within the block editor, and planning to make Text and Text Area fields editable directly in the main block editor view. This means that users will be able to click into those fields and start typing without needing to switch to edit mode. However, doing this with more complex fields, such as Repeaters and Flexible Content fields, will come later due to their complexity. Our goal is to maintain flexibility while improving the editing experience.

Q: Is there a change planned for directly updating ACF fields through the WooCommerce REST APIs?

A: Currently, there is no direct integration with the WooCommerce REST API. We recommend using our API for updating fields due to the complexity and security considerations involved. However, we are open to exploring this feature in the future, especially if users provide use cases that highlight the need for such integration.

Q: Is there a way to create a front end form that generates a draft custom post?

A: Yes! This can be achieved using ACF Forms, which allow users to submit data that can be saved as a draft post. Make sure to check out the August 2nd session of ACF Chat Fridays for a demo on how to do this.

Alternatively, you can use traditional PHP templates within a full-site editing WordPress site for simpler implementations. For example, you can output a front end form as a shortcode in a template, which then generates a draft post that an admin can approve. This approach can be particularly useful for scenarios where users need to fill out forms on the front end, and the data needs to be reviewed before being published.

Q: Can you use a hybrid approach with full site editing, combining traditional PHP templates with block editing?

A: Yes, you can still use traditional PHP templates for specific pages or post types within an FSE site, allowing for a hybrid approach. This means you can define certain templates in the old way while still using full site editing for other parts of the site. For instance, you might use traditional PHP templates for WooCommerce pages or custom post types, similar to how WooCommerce pages were defined before full site editing. This hybrid approach provides flexibility and allows you to leverage the strengths of both methods.

Resources & Links

Coming Up on ACF Chat Fridays

Register today for the next session of ACF Chat Fridays, taking place September 6th, 2024 at 2pm UTC. Questions and suggestions for the development team are always welcome.

Register for the next session of ACF Chat Fridays here:

https://wpeng.in/acf-chat-fridays/

The list of upcoming sessions is below.

  • October 4, 2024
  • November 1, 2024
  • December 6, 2024
  • January 3, 2025

Tag or DM us on Twitter to let us know you’ll be there. Suggest new topics, let us know what you’d like to see, and send us feedback with #ACFChatFridays on Twitter.

About the Author

For plugin support, please contact our support team directly, as comments aren't actively monitored.