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)

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.

  • i got this out, when i did print_r awesomescreenshot.com/06222evvc2 how i can use it get other things, like content in my query? – Nofel Dec 9 '13 at 11:02
  • You have to read up on the necessary basics yourself. @Nofel I've seen you have some answered questions you haven't taken care of, accepting answers and so on, can you do this please. – Nicolai Dec 9 '13 at 11:13
  • u need to give me coaching classes in woo :), not sure how i get product description, though i understood the links you provided me for API and classes. – Nofel Dec 9 '13 at 11:35
  • The description is the post_excerpt - take a look here or here. @Nofel Btw, by taking care of questions, I didn't just mean this one, you have others, doesn't have to be now, but if you got the time go through them. – Nicolai Dec 9 '13 at 11:38
  • i would use post_exceprt, but i am using shortcode, so i want description do come within that shortcode. – Nofel Dec 9 '13 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.