Retrieving custom field of a product (woocommerce)
-
Hi,
I’ve extended a product with a custom field and I’d like to retrieve it in backend (by putting code in CodeSnippet plugin) .
I retrieved (and printed out) all the products, however, there is no custom field there.
This is the code:// GET ALL THE PRODUCTS
$args = array('orderby' => 'ID', 'limit' => -1);
$products = wc_get_products($args);
foreach ( $products as $product ) {
$returnHTML .= print_r($product, true);
if(isset($product->my_field) ){
$returnHTML .= '---- WOHOOO FOUND IT -----';
}
}
return $returnHTML;Is there a way how to get this? I could’t find the answer anywhere.
Thanks a bunch!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Retrieving custom field of a product (woocommerce)’ is closed to new replies.