Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

In Woocommerce, I am trying to get product custom attribute values but I fail miserably and I don't get anything.

So I tried:

global $woocommerce, $post, $product;

$res = get_post_meta($product->id); print_r(unserialize($res['_product_attributes'][0]));

And I'm getting this raw data:

[pa_koostis] => Array

(

[name] => pa_koostis [value] =>

[position] => 0 [is_visible] => 1

[is_variation] => 0 [is_taxonomy] => 1

)

I know that there is a value because it is shown in the attribute section, but I just can't find a way to get it displayed with my custom code.

1 Answer

0 votes
by (106k points)
edited by

To get custom product attributes in Woocommerce you can use the following code:-

Want to learn  Angularjs  from basics! Here's the right video for you on  Angularjs provided by Intellipaat:

$result =array_shift(woocommerce_get_product_terms($product->id, 'pa_koostis', 'names'));

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Browse Categories

...