listing sku
-
I am new in Php/Wordpress world. I’ve been trying to list the sku for about 4 days, but I couldn’t do it. What I want is to get the sku codes of all the products (with their variations) registered in the woocommerce database. and I want to show these codes on a wordpress page I want.
I would have accomplished this in part with the code below.
` $args = array( 'post_type' => 'product', 'posts_per_page' => -1 ); $wcProductsArray = get_posts($args); if (count($wcProductsArray)) { foreach ($wcProductsArray as $productPost) { $productSKU = get_post_meta($productPost->ID, '_sku', true); $productTitle = get_the_title($productPost->ID); echo '<li>'.$productTitle.' - '.$productSKU.'</li>'; } }
`
But here is the problem: It only shows the main products and their codes. It does not show the variations and their SKUs. Could you please help me solve this. I’m about to go crazy!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘listing sku’ is closed to new replies.