Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Checkbox “Used for variations” under attributes hidden for custom product types

$
0
0

Replies: 0

when adding a custom product type, it is easy to modify the visibility of ‘inventory’ or ‘variations’ data tabs by using the woocommerce_product_data_tabs filter like:

add_filter('woocommerce_product_data_tabs','pluginname_add_cprt_data_tabs');
function pluginname_add_cprt_data_tabs($data_tabs){
    $data_tabs['inventory']['class'][] = 'show_if_cprt';
    $data_tabs['variations']['class'][] = 'show_if_cprt';

    return $meta_tabs;
}

And that works. However, there is no filter to make the ‘Used for variations’ checkbox under ‘Attributes’ data tab visible in a similar way. So while there is a filter to make the variations tab visible, there is no filter to actually get any variations from the attributes tab to the variations.

The checkbox is displayed as

<div class="enable_variation show_if_variable">
  <label><input type="checkbox" class="checkbox" <?php checked( $attribute->get_variation(), true ); ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /> <?php _e( 'Used for variations', 'woocommerce' ); ?>
  </label>
</div>

I solved it with jQuery that adds the class to .enable_variation but I believe a filter would be a nicer solution.


Viewing all articles
Browse latest Browse all 59525

Trending Articles