• Resolved arketype

    (@arketype)


    Hi,
    i have to insert a new input search in the backend search for the properties based on a custom value.

    I manage to add the input field adding lines in the plugin code in
    estatik/templates/admin/properties-archive/filter.php

    But when i try to use it nothing happens, i imagine i have to modify also some JS code but i can’t find where to add the lines i need.

    The input i wanna to filter is based on a number we give to every property, so for us is much easier searching for this ID instead of title or address.

    Hoping you can help us.
    Best regards

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Estatik

    (@estatik)

    Hi there,

    You need this file >> estatik-plugin/includes/classes/pages/admin/class-properties-archive-page.php

    There you will find the function – filter_query

    Using the filter below you can modify wp query and add your field.

    es_admin_properties_meta_query
    Thread Starter arketype

    (@arketype)

    Hi thanks for the reply.

    I’m not able to make it work, i pasted below the code.

    if ( ! empty( $_GET['entities_filter'] ) ) {
    		    $filter = $_GET['entities_filter'];
    
    		    foreach ( array( 'es_category', 'es_type', 'es_status' ) as $taxonomy ) {
    		        if ( ! empty( $filter[ $taxonomy ] ) ) {
                        $tax_query[] = array(
                            'taxonomy' => $taxonomy,
                            'field'    => 'id',
                            'terms'    => $filter[ $taxonomy ],
                        );
                    }
                }
    
                foreach ( array( 'country', 'state', 'province', 'city' ) as $location_field ) {
                    if ( ! empty( $filter[ $location_field ] ) ) {
                        $tax_query['es_location'][] = array( 'taxonomy' => 'es_location', 'field' => 'id', 'terms' => $filter[ $location_field ] );
                    }
                }
    
                if ( ! empty( $filter['date_added'] ) ) {
                    $value = DateTime::createFromFormat( ests( 'date_format' ), $filter['date_added'] );
                    $query->set( 'year', $value->format( 'Y' ) );
                    $query->set( 'day', $value->format( 'd' ) );
                    $query->set( 'monthnum', $value->format( 'm' ) );
                }
    
                if ( ! empty( $filter['price_min'] ) ) {
                    $meta_query['price_min'] = array(
                        'value' => $filter['price_min'],
                        'key' => 'es_property_price',
                        'type' => 'NUMERIC',
                        'compare' => '>=',
                    );
                }
    
                if ( ! empty( $filter['price_max'] ) ) {
                    $meta_query['price_max'] = array(
                        'key' => 'es_property_price',
                        'value' => $filter['price_max'],
                        'type' => 'NUMERIC',
                        'compare' => '<=',
                    );
                }
    
                if ( ! empty( $filter['s'] ) ) {
                    $meta_query['keywords'] = array(
                        'key' => 'es_property_keywords',
                        'value' => $filter['s'],
                        'compare' => 'LIKE'
                    );
                }
    			
    			 if ( ! empty( $filter['idimmobile'] ) ) {
                    $meta_query['idimmobile'] = array(
                        'key' => 'id_immobile',
                        'value' => $filter['idimmobile'],
                        'compare' => 'LIKE'
                    );
                }
            }
    
            if ( ! empty( $tax_query ) ) {
    		    $query->set( 'tax_query', apply_filters( 'es_admin_properties_tax_query', $tax_query, $query ) );
            }
    
    		if ( ! empty( $meta_query ) ) {
    			$query->set( 'meta_query', apply_filters( 'es_admin_properties_meta_query', $meta_query, $query ) );
    		}
    
            return $query;
        }

    The filter i’m trying to add is the “idimmobile”.
    The ID of the listing field i created is “id_immobile”, but i can’t find how to make it works.

    To me it seems all right but when i try to search with it, i just receive empty results.

    I hope you can help me.
    Best regards.

    Thread Starter arketype

    (@arketype)

    Hi there,
    i didn’t receive any answer, can you help me fix this problem?
    I have still no success implementing this kind of search in the backend.

    Best regards.

    $filter['idimmobile']

    You must make sure that this variable has your value.

    If you need us to make the necessary customization, please contact us through the form and we will try to help you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Backend properties search’ is closed to new replies.