woocommerce stored variable

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.

  1. How can i get to know, which variable does woocommerce uses to store the data.
  2. 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)

Related posts

1 comment

  1. 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:

    $product = get_product( $post->ID );
    

    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:

    $all_meta = get_post_meta( get_the_ID() );
    echo $all_meta;
    

    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.

Comments are closed.