How to get the original price of the product in woocommerce?

I’m pretty sure that the problem is, that the WP_Query returns post objects, which are not identical to Woocommerces product objects. While you are trying to get the product data by getting the according global, that won’t work, especially because the query you are performing does nothing to that global. Now what I probably would do is, firstly, performing the query with the fields parameter set to ids. Secondly, when looping over the returned array of ids, I would suggest you get the product object with wc_get_product(), which should give you all the information you need.


Note: I answered this to enlighten about the difference in return between WordPress’ and Woocommerces object. And to make clear, while product is a CPT it isn’t necessarily optimally usable with WP’s standard query. There is a strong argument though for your question being off topic, because it is about a third party plugin. Please take a look at our help center to learn more about our site guidelines.

Leave a Comment