Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the data from a protected Meta data object in Woocommerce

I need to get the value of ntva from this Object but I can't figure out how to do it.

Meta_data Object ( [current_data:protected] => Array ( [id] => 99769 [key] => ntva [value] => SRTTE ) [data:protected] => Array ( [id] => 99769 [key] => ntva [value] => SRTTE ) );

Foreach ($data->current_data as $key => $value){ 
echo $key.', value'.$value.'<br/>';
}

This foreach does not show me anything.

This object comes from WooCommerce (e-commerce wordpress plugin) ORDER data array. I need the ntva value to display it in PDF invoice.

like image 449
Houx Avatar asked Oct 16 '25 04:10

Houx


1 Answers

Looking at the source, WC_Meta_Data has a getter __get, so you will be able to access it like:

$data->key which will output ntva

Or use the get_data() method:

foreach ($data->get_data() as $key => $value){ 
    echo $key.', value'.$value.'<br/>';
}
like image 195
Lawrence Cherone Avatar answered Oct 18 '25 16:10

Lawrence Cherone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!