Can I display specific WooCommerce Attributes in a layout?

Hello,

Thank you for the question. It’s kind of a tough one to answer/solve, but it helps me see what might be missing from the plugin and its documentation.


About Beaver Builder’s Product Grid module - its “custom layout” field supports regular HTML and shortcodes, but not dynamic tags provided by Loops & Logic. (In other words, L&L doesn’t yet integrate with the field specifically.)

You can use the [template] shortcode (documented here) to load from the Template post type in the admin. So, it’d be necessary to:

  • Create a template post
  • Load it in the custom layout, like: [template id=7]

Since all you need is to show a product attribute, it would be nice if the shortcode also supported putting a template directly in its inner content, like [template]..[/template]. It should be easy to add this feature, I’ve made a note of it.


About the loop type woo_product, it’s provided by a separate add-on called Loops for WooCommerce, which is not publicly released yet. It’s also planned to be a premium product, like the other add-ons for third-party plugin integrations. So, that should be made clearer in its documentation. (We will likely do a beta testing phase of these add-ons soon.)

That said, the L&L core plugin should be capable of handling any post type and field, at least as “raw” values.

Since the Product Grid module already creates a product loop to render the custom HTML layout for each product, I believe just the Field tag is enough to display the product attribute.

Trying this on a local site, I see that product attributes are in a field called attributes, which is a “map” (associative array). Each attribute is inside of it as a “subfield”. That would be accessed like this:

<Field attributes field=pa_flavors />

…Hmm, I see that the above doesn’t work as expected. Looking at the attributes field itself:

<Field attributes />

This shows something like: {"pa_flavors":{}}.

Well, it looks like product attributes need special processing, and cannot be accessed as raw values. Too bad, it seemed so close!

OK, I’ve made a note to look into it deeper. We’ll probably need to add support for product attributes in the add-on, Loops for WooCommerce.

1 Like