Implementing product attributes with layout-builder

Hi,

Currently I’m designing the single-product-page with your layout-builder but I can’t finde a way to display some of the product attributes in the frontend.

Is there a way to implement this without using another plugin?

Page: test.weingut-gager.at

You could see what I mean in the screenshots.

Hello @muse_83,

Thanks for writing to us.

To display the product attributes you can use the dynamic content code.
{{dc:woocommerce:product_additional_information}}

Please have a look at the given screenshot below.
Testsingle-Layout-Builder-Pro

Thanks

Hi,

Actually that’s not a solution because it prints all product attributes and values, but I only want to display specific values (without the labels) of two specific product attributes as you could see in the screenshots. Is there a way to implement it in the layout?

Here is a screenshot of one of those elements I want to display in the frontend:

Is there a simple way to implement this element in the layout?

PS: Please also take a look at my previous screenshots, there you could see how I want to implement it.

Best,
Sebastian

Hi Sebastian,

The Product Attributes has a different structure than the regular terms* and that is why it is not currently supported in Dynamic Content tags. Alternatively, you can use the ACF PRO, instead of using the native WC Product Attributes. Please find the detailed documentation on the ACF Pro

Also, you can create a shortcode that returns a specific attribute, and use it wherever you want. The shortcode will look like the following one.

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'); // your attribute name
    return $book_language;
}

Please remember that the above code will work if copied as it is and doesn’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes which means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

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