1
Good! I’m making a plugin for Woocommerce based on the Wc_integration extension that they suggest.
In short, I am trying to access the list of Woocoomerce products via php. Until I see I am free of errors in the PHP part, but I have been trying to print the variables for the Inspect log, although I am not getting it, php also does not throw errors. Any idea what it might be? The Code is inserted in a class hence the "public Function".
public function get_woo_products(){
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$products = wc_get_products($args);
foreach ( $products as $product ) {
$product_id = $product->get_id();
$product_name = $product->get_name();
$product_sku = $product->get_sku();
$product_price = $product->get_price();
$image_url = wp_get_attachment_image_src( $product->get_image_id() );
$custom_value = $product->get_meta('_custom_key');
echo "<script>console.log('Debug Objects: " . $product_name . "' );</script>";
}
}
@Woss Updated!
– André Garcia