Support

Account

Forum Replies Created

  • In fact, it needs some additional code to work like a charm :

    add_filter('acf/location/rule_match/woocommerce_category', 'acf_location_rules_match_woocommerce_category', 10, 3);
    function acf_location_rules_match_woocommerce_category( $match, $rule, $options )
    {
    
        global $post;
        $terms = get_the_terms( $post->ID, 'product_cat' );
    
        $selected_category = (string) $rule['value'];
    
        if ( $terms && ! is_wp_error( $terms ) ) {
    
            if ( $rule['operator'] == "==" ) {
    
                foreach ( $terms as $term ) {
    
                    $match = ( $term->name == $selected_category );
    
                }
    
            } elseif ( $rule['operator'] == "!=" ) {
    
                foreach ( $terms as $term ) {
    
                    $match = ( $term->name != $selected_category );
    
                }
            }
        }
    
        return $match;
    }
  • Hello,

    I think it’s because of this line :

    $selected_category = (int) $rule['My Product Category Name'];

    It’s not an integer and it should be ‘value’ instead of ‘My Product Category Name’ I think, so :

    $selected_category = (string) $rule['value'];

    Works for me.

    Regards,

    Deodat

  • Well I’ve deleted and re-created my custom field (color picker for taxonomy term) with the version 5.2.1 and it worked (doesn’t understand why it didn’t work with my old custom field but I don’t care)

  • Doesn’t work for me 🙁
    Indeed the term taxonomy is now well assigned after updating but the custom field defined with this condition (i.e. color picker) doesn’t appear in my custom taxonomy as it did in 5.1.9
    I’m rolling back to this last workin version.

  • The same, the last update 5.2.1 doesn’t solve the issue. Hélas.

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