I am using NAME YOUR PRICE PLUGIN and in the Checkout page of my WordPress site, i need to get the price value (300) of this WordPress Object. So i ahev set a loop in my functions.php.
But i don’t know how to do to target this specifc attribute.
Thanks for help
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$cart_product = $values['data'];
print_r ($values['data']);
}
WC_Product_Simple Object
(
[object_type:protected] => product
[post_type:protected] => product
[cache_group:protected] => products
[data:protected] => Array
(
[name] => Faire un don
[slug] => don
[date_created] => WC_DateTime Object
(
[utc_offset:protected] => 0
March 5, 2020 => 2019-10-25 11:15:27.000000
[timezone_type] => 3
[timezone] => Europe/Paris
)
[status] => publish
[featured] =>
[sku] => don
...
[purchase_note] =>
)
[supports:protected] => Array
(
[0] => ajax_add_to_cart
)
[id:protected] => 969
[changes:protected] => Array
(
[price] => 300
[sale_price] => 300
[regular_price] => 300
)
[object_read:protected] => 1
[extra_data:protected] => Array
(
)
)
)
2
Answers
Because of the previous answers just targeted the frist attribute PRICE, i finally found a solution with this method:
Hope this helps you.