0

When I try to get all product attributes they don't have any values.

$tmpBk = get_post_meta(10763, '_product_attributes',true);
print_r($tmpBk);

Response -

Array ( [pa_brand] => Array ( [name] => pa_brand [value] => [position] => 1 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_package-size] => Array ( [name] => pa_package-size [value] => [position] => 2 [is_visible] => 1 [is_variation] => 1 [is_taxonomy] => 1 ) [pa_volume] => Array ( [name] => pa_volume [value] => [position] => 3 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_abv] => Array ( [name] => pa_abv [value] => [position] => 4 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_type-2] => Array ( [name] => pa_type-2 [value] => [position] => 6 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) )

But It shows values in the backend & Frontend. Where are these values stored? & How do I add/update them programatically ?

enter image description here

Shivam Kamat
  • 121
  • 12

1 Answers1

0

I hope I got your question right.

See get meta data on on developer.wordpress.org. In the user comments, there are some examples of how to get the values.

Additionally, WooCommerce installs some custom tables to store its data during install, see woocommerce database description on github - have a look in the tables woocommerce_order_items and woocommerce_order_itemmeta.

To add and update data, you can use

This blog post which contains a good summary.

For the last part, I am not completely sure how I can answer how to add data programmatically. A good start for you could be this SO post about updating post meta to add product attributes

Christian
  • 4,902
  • 4
  • 24
  • 42