Skip Navigation

[Gelöst] decimal value not filtering

This support ticket is created vor 7 Jahren, 6 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Shane vor 7 Jahren, 6 Monaten.

Assistiert von: Shane.

Author
Artikel
#521675

hi. i read this post :
https://toolset.com/forums/topic/parametric-search-results-are-wrong-because-cast-as-decimal-return-wrong-values/

i am having the same issue now too.

my case is i have value such as 1,1.5 ,2,2.5,3,3.5 etc.

my custom search could not filter value between 1-2. i have result of 2.5 too.which is wrong.

Please advice.

#521676
#521756

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

This issue should've been fixed in our views plugin since version 2.2.1

However could you try this filter below and let me know if it helps.

function wpv_filter_query_cast_as_decimal_fix( $query, $view_settings, $view_id ) {
        if ( isset($query['meta_query']) ) {
            foreach ( $query['meta_query'] as $key => $value ) {
                if ( isset( $value['type'] ) ) {
                    if ( strtoupper( $value['type'] ) == 'DECIMAL' ){
                        $query['meta_query'][$key]['type'] = 'DECIMAL(11,2)';
                    }
                }
            }
        }

        return $query;
    }
add_filter( 'wpv_filter_query', 'wpv_filter_query_cast_as_decimal_fix', 99, 3 );

Add the above to your functions.php file.

Thanks,
Shane

#521853

Yes i do see decimal field after selecting number, it appear only after i edit that field back.

Btw may i know how do i confirm that the attributes are applied well.?
i believe is at database? could you point me the location please. thanks

#522129

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hello,

The field would be in the database, does your view filter correctly with the decimals now ?

Could you confirm this ?

Thanks,
Shane

#522132

Yes It does, thanks.

I am also hard-coding the field as i need other attributes which is not in the options, thus i need to check the database that the attributes are stored correctly, could you point me a sample please. thanks

#522141

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hello,

The field should be stored in the post_meta table in your database under the name wpcf-{custom field slug}

Try searching your database for this. However it should be stored correctly without any issues.

THanks,
Shane