The number of products displayed on the page clears all selected product filters – woocommerce

I have a problem on the Product archive, when I filter products and change the number of displayed products per page, all the set filters are reset.

I’ve noticed that both the filter and the number of products on the page also enter their attributes in the URL, and that’s probably the problem. Does anyone have any solution for this?

enter image description here

Filtered products: http://xxx.xxx/product-category/spirits/?ixwpst[pa_brand[]=25&ixwpst[pa_brand[]=28&title=1&excerpt=1&content=1&categories=1&attributes=1&tags=1&sku=1&ixwpsf[pa_brand][show]=all&ixwpsf[taxonomy][pa_brand][multiple]=1&ixwpsf[taxonomy][pa_brand][filter]=0&ixwpsf[taxonomy][pa_region][show]=all&ixwpsf[taxonomy][pa_region][multiple]=1&ixwpsf[taxonomy][pa_region][filter]=0&ixwpsf[taxonomy][pa_detail-type-1][show]=all&ixwpsf[taxonomy][pa_detail-type-1][multiple]=1&ixwpsf[taxonomy][pa_detail-type-1][filter]=0&ixwpsf[taxonomy][pa_detail-type-2][show]=all&ixwpsf[taxonomy][pa_detail-type-2][multiple]=1&ixwpsf[taxonomy][pa_detail-type-2][filter]=0

Displaying number of products on page: http://xxx.xx/product-category/spirits/?Products-per-page=48

filters – Agricultural spectrum photography and NIR

I am looking into different cameras or sensors that i could use to measure the following em ranges that are useful to agriculture. I’m hoping to construct an open source device(s) to measure the following within a small and reproducible device(s):

Cellulose Absorption Index: 2000-2200nm

Plant Water Index: 902-970nm

Disease Water Stress Index: 547-1657nm

NDVI 670-800nm

I am also looking for filters or filter combinations for the following ranges:

Cellulose Absorption Index: 2000-2200nm

Plant Water Index: 902-970nm

Disease Water Stress Index: 547-1657nm

Thanks

magento2.3 – Magento2 Grid: Select all disabled with two dropdown filters

A client running a magento 2.3.2. store noted that he can not use the Select All when two Filters are enabled. This pertains to the Magento Grid with orders on the Sales page. The filters the client is using are Status & Storeview.

I tested this behavior and can confirm that when he uses 2 Dropdown filters, the Select All functionality gets disabled. The disabling works through adding a ‘disabled’ attribute to both the input & button element. Other combinations of filters do not seem to have this behavior. When I manually remove the attributes (devtools) the functionality seems to work properly.

My questions.

  1. Is there a good reason why the ‘Select All’ gets disabled on selecting 2 dropdown filters? The disabling seems intentional, so I figure it is not a bug?

  2. If there is no reason, I might want to adjust this behavior. Could you point me in the right direction to where this behavior is set?

I appreciate any helpful input.

logging – How to test filters in syslog-ng?

I would like to send to a telegram bot any successful ssh connections so I wrote this:

filter f_ssh { facility(auth) and match("sshd" value("Accepted.+?ssh2")); };

And later:

log { source(src); filter(f_ssh); destination(d_telegram); };

Unfortunately I never receive anything and it is very cumbersome to change-config, reload, ssh to test if the filter works.

Is there anyway to test the filter before applying?

api design – Long variable naming with chained filters on API best practices?

I am writing an application where a single variable may be affected by different filters applied to the data that’s read from the DB. Each different variation has to be stored (as each one serves different purposes) in different variables, however, I’m not sure about the best naming convention for this cases as it will become a public-accessible API at some point. A simple example:

  • meterPrice: original name.
  • meterPriceBySuburb: new variable with a suburb filter.
  • meterPriceBySuburbByType: new variable with the suburb and type filters.
  • meterPriceBySuburbByTypeBySchool: you get the point.

I have 2 main concerns with the naming that should be followed for these variables:

  1. Some variables names, following this format, can get way too long, the longer one we are planning on creating being something like: MeterPriceDistributionChartDataBySuburbByTypeBySimilarity. Does the longitude itself be a problem on a public-facing API?
  2. What is the convention or, at least, the best practice for chaining these filters? Currently I have thought about 4 different schemas:

    • meterPriceBySuburbTypeSimilarity: One after another after first By.
    • meterPriceBySuburbByTypeBySimilarity: Having By before each filter.
    • meterPriceBySuburbAndTypeAndSimilarity: Having a first By and then follow each new one with And.
    • meterPriceBySuburbTypeAndSimilarity: Having an initial By and just add Andto the final filter.

Thanks in advance for any responses! And sorry for my bad english.

magento2 – Apply filters or mass actions on grids with fake collection (or wirhout ui components)

I a admin grid with a change on _prepareCollection() function to get the collection from a response of api call, its working fine. But I do not have the filters or mass functions, how can I do that without ui components?

enter image description here

I have this change on my grid file:

/**
 * Collection
 *
 */
protected function _prepareCollection()
{
    $filter = (
        'query' => 'cat yellow',
        'page' => 1,
        'region' => '',
        'year' => '',
    );

    $collection = $this->_api->searchCat($filter);

    $this->setCollection($collection);
    return parent::_prepareCollection();
}

If I could simulate a collection, maybe I could use ui components, but I’m lost, how can I resolve my problem?

The idea is use the filter to search cats with cat api, and the mass action is to import those registers into a products.

filters – post value to function with Ajax and jQuery

This is how you would create a custom smart tag in wp forms:

function ea_custom_smart_tags( $content, $tag ) {
    if( 'my_smart_tag' == $tag ) {
        $value = 'Testing 1 2 3';
        $content = str_replace( '{' . $tag . '}', $value, $content );
    }
    return $content;
}
add_filter( 'wpforms_smart_tag_process', 'ea_custom_smart_tags', 10, 2 );

I want to post a value via ajax instead of hard coding it.

My jQuery/ajax:

jQuery.ajax({
    type: 'POST',
    url: 'http://localhost:8888/mywebsite/wp-admin/admin-ajax.php',
    data: {
        action: 'my_action',
        theTotal: newTotal
    },
}).success(function (result) {
    alert(result);
});

My functions.php:

function my_action_callback($content, $tag){


if ( 'total' === $tag ) {

 $total = $_POST('theTotal');

 $content = str_replace( '{total}', $total, $content );

}

return $content;
}
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_filter( 'wpforms_smart_tag_process', 'my_action_callback', 10, 2 );

This is however giving me an error:

Uncaught ArgumentCountError: Too few arguments to function
my_action_callback(), 1 passed in and exactly 2 expected

Searchview with Recyclerview in Android using Volley per pagin How to add search filters to the last page in a recycler view that consumes ten page?

I am doing a search filter by identity document in a Recyclerview that is per page, the problem is that at the time of making the filter it only looks for the first diez that is the current page. How would I filter the search from the current page until last page?

RecyclerActasAdapter.java

  @Override
    public int getItemCount() {
        return this.itemsMostrados.size();
    }

    public void filtrar(String query) {
        this.itemsMostrados = new ArrayList<>();

        if (query.length() == 0) {
            itemsMostrados = listaActas;
            layoutResultados.setVisibility(View.GONE);
        } else {
            ActasActivity actas= new ActasActivity();
            for (Datum data: listaActas) {
                if (data.getBeneficiario().getNumDocumento().contains(query)
                    //|| (data.getBeneficiario().getNombre().toLowerCase() + " " + data.getBeneficiario().getApellido().toLowerCase()).contains(text.toLowerCase())
                    || (data.getBeneficiario() != null ? data.getBeneficiario().getNombre() : "No registra" + " " + data.getBeneficiario() != null ? data.getBeneficiario().getApellido() : "No registra").contains(query)
                    //|| data.getPoblacion().getNombre().toLowerCase().contains(text.toLowerCase())
                    //|| data.getMunicipio().getMunicipio().toLowerCase().contains(text.toLowerCase())
                    ) {
                    itemsMostrados.add(data);

                }
            }

            layoutResultados.setVisibility(View.VISIBLE);
            txtResults.setText(itemsMostrados.size() + "");

        }

        notifyDataSetChanged();
    }

    public void actualizar() {
        itemsMostrados = listaActas;
        notifyDataSetChanged();
    }


ActasActivity.java

In this activity I try to create the condition to filter search to the last page but still continue to filter only the first 10 of the current page

  public void obtenerActas(boolean inicializar) {

        if (inicializar) {
            current_page = 1;
            last_page = 1;
            last_size_pages = 0;
        }

        final Promise<RespuestaActasDTO, BusinessException, RespuestaActasDTO> mPromise = actasService.obtenerActas(current_page);
        mPromise.done(result -> {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }

            actualizarListadoActas(result, inicializar);

            if (progressBar.getVisibility() == View.VISIBLE) {
                progressBar.setVisibility(View.GONE);
            }

        });
        mPromise.fail(error -> {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }

            if (progressBar.getVisibility() == View.VISIBLE) {
                progressBar.setVisibility(View.GONE);
            }

            Toast.makeText(mContexto, "Ocurrió un error consultando las actas", Toast.LENGTH_SHORT).show();
        });
    }

    public void actualizarListadoActas(RespuestaActasDTO respuestaActasDTO, boolean inicializar) {

        // logica para controlar la pagina a consumir y saber cual es la ultima pagina
        last_page = respuestaActasDTO.getLastPage();

        //SI PAGINA ACTUAL ES MENOR QUE ULTIMA PAGINA
        if (current_page < last_page) {
            current_page++;//ENUMEREME DESDE LA PAGINA ACTUAL

        }

        if (actasAdapter == null || inicializar) {
            listaActas = new ArrayList<>();
            listaActas = respuestaActasDTO.getData();

            actasAdapter = new RecyclerActasAdapter(mContexto, listaActas, layoutResultados, txtResults);
            recyclerViewActas.setAdapter(actasAdapter);
            scrollListener.resetState();
        } else {
            //página actual <   última página
            if (current_page < last_page) {
                listaActas.addAll(respuestaActasDTO.getData());
                actasAdapter.actualizar();

                agregarUltimaConsulta = true;
            } else if (current_page == last_page) {
                if (agregarUltimaConsulta) {
                    agregarUltimaConsulta = false;
                    last_size_pages = respuestaActasDTO.getData().size();
                    ultimaLista = respuestaActasDTO.getData();

                    listaActas.addAll(ultimaLista);
                    actasAdapter.actualizar();
                } else if (last_size_pages != respuestaActasDTO.getData().size()) {
                    // limpiar ultimos registros para volverlos a agregar

                    ultimaLista = respuestaActasDTO.getData();
                    last_size_pages = respuestaActasDTO.getData().size();

                    listaActas.addAll(ultimaLista);
                    actasAdapter.actualizar();
                }
            }
        }
        // Logical END to control the page to consume and know which is the last page ------>>>>


        if (agregarEventoBuscar) {
            agregarEventoBuscar = false;
            // buscador
            inputBuscar.setOnQueryTextListener( new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String query) {
                    actasAdapter.filtrar(inputBuscar.getQuery().toString() );
                    return true;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    return false;
                }
            } );

        }


Observation: I only filter the query if I scroll to the last page, Thanks for your support

filters – how to unescape wordpress output

I am having to hook into a plugin and I need to actually output a value I get via jQuery. However, when I try to return it (I have to use return) it just escapes the javascript instead of actually giving me the value. So, the output on the screen is literally the text instead of the value ie: <script>document.write(buttontext);</script> instead of some value

<script>
var myValue = jQuery( '.my_value' ).val();
<?php 
     $myValue ="<script>document.write(buttontext);</script>";             
 ?>
</script>
<?php
//.... some code.. $myValue ends up in $content which I return below
return $content;
?>