Pergunta

On the admin side generating metabox data.

function prod_a( $value ){
    global $post;
    global $product; // This === null. Thus the query bellow. 
    $args = array(
         'post_type'     => 'product_variation',
         'post_status'   => array( 'private', 'publish' ),
         'numberposts'   => -1,
         'orderby'       => 'menu_order',
         'order'         => 'asc',
         'post_parent'   => $post->ID
    );
    $variations = get_posts( $args );
    foreach ($variations as $v) {
        $meta = get_post_taxonomies($post->ID );
        var_dump($meta);
    }
    ...
}

The dump contains an array of all the registered taxonomies. Looks like:

array (size=8)
0 => string 'product_type' (length=12)
1 => string 'product_cat' (length=11)
2 => string 'product_tag' (length=11)
3 => string 'product_shipping_class' (length=22)
4 => string 'pa_finish' (length=9)
5 => string 'pa_collars' (length=10)
6 => string 'pa_mounting' (length=11)
7 => string 'pa_sizing' (length=9)

I can work with these results but what I'm really looking for is what to get the taxonomies added but the user. Taxonomies that have the 'pa_' prefix.

Foi útil?

Solução

function prod_a( $value ){
    global $post;
    $_pf = new WC_Product_Factory();  
    $_product = $_pf->get_product($post->ID);
    $available_variations = $_product->get_available_variations();
    var_dump($available_variations);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top