Support

Account

Home Forums Front-end Issues WooCommerce widget with ACF included

Helping

WooCommerce widget with ACF included

  • I have created a taxonomy for Woo product attributed (colour).

    On the achieve page, I’ve added a widget to filter by colour.

    I want to adjust the filter to include the ACF field colour as well. But, so far I’ve been unable to find a solution.

    Can anyone assist, please?

  • Ok, I’ve been able to a bit further and can edit the widgets now.

    I’ve created an IF statement so that if the colour hasn’t been selected it will not show.

    However, they’re all coming back “no” despite 2 colours having selected.

    function woo_colour_swatches( $term_html, $term, $link, $count ) {
        
        $color = get_field('colour', $term);
    
        if( $colour ){
            echo 'Yes';
        }else{
            echo 'No';
        }
    
        echo '<a href=" '. $link .' ">'. $term->name .'</a>';
    
        return $some_modified_value;
    }
    add_filter( 'woocommerce_layered_nav_term_html', 'woo_colour_swatches', 10, 4 );

    **UPDATE**

    Mis-spelt color with colour

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.