Changes to variable products in 2.2
-
Hi there
Since updating to 2.2 one of my plugins no longer works. I’ve pasted the problem function below. I’ve changed it slightly with no success – I used to just declare ‘global $product;’, i’ve changed that to $product = new WC_Product($theid);..
Any suggestions?
// ********* Get all products and variation and sort alphabetically, return in array (title, sku, id)******* function get_alphabetic_product_list() { $full_product_list = array(); $loop = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => -1 ) ); while ( $loop->have_posts() ) : $loop->the_post(); $theid = get_the_ID(); // global $woocommerce, $post, $product; $product = new WC_Product($theid); // it's a variable product.. if( $product->is_type( 'variable' ) ){ $available_variations = $product->get_available_variations(); $attributes = $product->get_attributes(); foreach ($available_variations as $prod_variation) : $post_id = $prod_variation['variation_id']; $post_object = get_post($post_id); $sku = $prod_variation['sku']; $full_product_list[] = array(get_the_title(),$sku, $post_id); endforeach; } else { // it's a standard product... $sku = $product->get_sku(); $full_product_list[] = array(get_the_title(), $sku, $theid); } endwhile; wp_reset_query(); sort($full_product_list); return $full_product_list; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Changes to variable products in 2.2’ is closed to new replies.