Dynamic content for product attribute

Hello there.
I am developing a product layout for second-hand books in WooCommerce. On every item I have added a “Language” attribute e.g. English, French, German and would like to display this in my layout. I’ve looked through all the DC fields but can’t see a reference to it. Am I missing something obvious?
Kindest regards,
Phil.

Hi @pmason,

Thanks for reaching out!

There’s no dynamic content to display the product attributes. On the other hand, are you using product as variables to get the product’s attributes? I suggest that use the add to cart from element to display the product attributes.

Hope that helps.

Hi Marc.
Thanks for taking a look. I’m afraid that’s not really what I was looking for. The beauty of a layout should be that you can build it exactly as you wish. It’s hard to believe that we can’t access product attributes directly through DC? Can they be referenced through a looper perhaps? Or do you have any other ideas?
Kindest regards,
Phil.

Hi Phil,

The Product Attributes has a different structure than the regular terms * and that is why it is not currently supported in Dynamic Content tags.

An alternative is, instead of using the native WC Product Attributes, you can use the ACF PRO
https://theme.co/docs/acf-pro

Thanks for understanding,

Hello, I just wanted to publish the solution I found, so that othjers can benefit from it, if they are wanting to do something similar.

In a Headline element I had the following text and shortcode call.

Language: [product_attributes]

In my functions.php I created my shortcode.

add_shortcode( ‘product_attributes’, ‘get_product_language’ );

function get_product_language() {

global $product;

$product_attributes = $product->get_attributes();

$book_language = $product->get_attribute(‘pa_language’);

return $book_language;

}

2 Likes

Hi @pmason,

Thanks for sharing your solution, we really appreciate it.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.