In wordpress, all information can be retrieved via $post
or wp_query
, in woocommerce, is there something similar? I want to display information of each product, on a page next to the picture. I have two questions.
- How can i get to know, which variable does woocommerce uses to store the data.
- In General, if we want to know the meta of any post,page, how can we pull it aganist each id, where id is generic (we don’t know, its dynamic like
$post->ID
)
There is
$woocommerce
, which is is crucial. Several classes stored into this, see woocommerce class reference and additionally WC API Docs.If you’re looking for product information:
is certainly a good entry point. If you’re already on a product page or generally in the wc loop, you often have
$product
already available.Another thing to add is, wc product(s) are are just a custom post type, so you can do a lot by using wordpress core functions – like:
But for some things you need or at least it’s easier to use wc functions, to know these you have to read the plugins documentation, e.g. useful functions. Same applies to action and filter hooks.
Generally, take a closer look at the linked – and the not linked – information, the source and the variables/objects themselves to get deeper into that.