I'm using the Unite Theme with Woocommerce and need to replace the wc_get_product_cat_class function. After an entire night trying to figure it out, I have found that the following is stored in /wp-content/plugins/woocommerce/includes/wc-template-functions.php
// Display the classes for the product cat div.
function wc_product_cat_class( $class = '', $category = null){
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . esc_attr( join( ' ', wc_get_product_cat_class( $class, $category ) ) ) . '"';
}
// Get the classes for the product cat div.
function wc_get_product_cat_class( $class = '', $category = null ){
global $woocommerce_loop;
$classes = is_array( $class ) ? $class : array_map( 'trim', explode( ' ', $class ) );
$classes[] = 'product';
if ( 0 === ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] ) {
$classes[] = 'first';
}
if ( 0 === $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) {
$classes[] = 'last';
}
$classes = apply_filters( 'product_cat_class', $classes, $class, $category );
return array_unique( array_filter( $classes ) );
}
I have already created a functions.php file in my child theme already. How do I remove and replace the wc_get_product_cat_class function?
As I understand it the functions.php file in the child theme loads first, but in the absence of a if(! line in the wc-template-functions.php, I am unable to simple add and amend the above to my own functions file.
product_cat_class? And what modifications do you need to make? - helgatheviking