1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Filter field classes
  1. Home
  2. Knowledge Base
  3. Advanced Topics for Add-Ons Ultimate
  4. Filter field classes

Filter field classes

You can filter the class applied to each product extra field, just use the pewc_filter_single_product_classes filter:

<?php
/**
* Filter field classes
*/
function prefix_filter_single_product_classes( $classes, $item ) {
$classes[] = 'my-class-name';
// You can also use $item to check the field ID and add classes conditionally
return $classes;
}
add_filter( 'pewc_filter_single_product_classes', 'prefix_filter_single_product_classes', 10, 2 );

The filter also passes the $item object so you can do conditional stuff based on the item.

Was this article helpful?

Related Articles