Unfortunately, I am not as strong as I would like to be in pHp, so I could ask a fairly simple question.
I'm just trying to figure out why I cannot print the individual values of the product array.
print_r ($ product) returns:
WC_Product_Simple Object (
[id] => 72
[post] => WP_Post Object (
[ID] => 72
[post_author] => 1
[post_date] => 2015-09-23 21:54:50
[post_date_gmt] => 2015-09-23 21:54:50
[post_content] =>
[post_title] => Simple Product
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => closed
[post_password] =>
[post_name] => simple-product-1
[to_ping] =>
[pinged] =>
[post_modified] => 2015-09-23 21:55:48
[post_modified_gmt] => 2015-09-23 21:55:48
[post_content_filtered] =>
[post_parent] => 71
[guid] => http:
[menu_order] => 0
[post_type] => product
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
),
[product_type] => simple
[shipping_class:protected] =>
[shipping_class_id:protected] => 0
[downloadable] => no
[regular_price] => 10
[price] => 10
[tax_status] => taxable
[manage_stock] => no
[stock_status] => instock
)
I tried
echo $product->post_parent;
But that does not work.
So i tried
echo $product[0];
But it prints a mistake.
I feel that the first option works, I just don’t expect it, so I hope I can explain why it does not work, and what I should do instead.
Thanks!
source
share