Hey guys.
I have a page that lists countries by a repeat region that takes the list of countries from the bank and shows it with a checkbox. I can filter by a single country when I click on the checkbox or choose in select and the URL looks like this: journeys-teste?country=BRA
What I need is to filter the products by more than one country separated by a comma in the URL. Example: journeys-teste?country=BRA,CHI,ITA. It then returns products that have related country codes in the COUNTRIES field array.
In the database I saved the countries as ARRAY [“BRA”,“CHI”] through tagify.
I already tried to do a server connect with the condition {{$_GET.country.split(’,’)}} to get the URL separated by a comma but I couldn’t. I have also transformed the GET field in server connect into ARRAY.
What am I missing here?
Hello @Cheese and thanks for the response.
But what I need is to filter by the URL type test?country=ARG,BRA,FRA,ITA. Therefore, all products that have these countries in the field will appear in the result. Some products have only one country but others may have more than one in the COUNTRY field separated by a comma.
I can already filter by a single country but several in the URL separated by commas I cannot.
You will need to replace those commas and URL encode, and then on the server side decode and split as far as I know…? Maybe one of the Team can offer some advice. I’ll admit it is not something we have done nor had the need to do so it is fresh territory for me personally.
Hello agian, @famousmag.
This is the field structure in the table. I saved the country codes in a tagify field on the product edit page. Some products only have one country but others have 4 or 5. An array is saved in the field.
“pct_code_pais” column looks wrong.
The values need to be regular string for the query to work, as you have configured it.
Each column should have one value, without the quotes or brackets.
This is assuming the data type of this field is varchar. If not, then this is a different problem.
Hello.
This pattern [“AUS”,“ARG”] is how the tagify field is saving to the field. Even if I put AUS,ARG in the field, the filter only recognizes one country.
To filter I have a select field that filters only the country code that is in the pct_code_pais field in the table, for example AUS. But if I put AUS,ARG in the same field it no longer returns results. What I need is for it to return results where it has the AUS or ITA code.
I can’t save it as array [“AUS”,“ARG”] ?
I’m confused as to why you’re not using the method I showed you in your other post. There’s no need to pass values through the URL, you can pass the values straight to the server connect and it will function just as it does here https://dashboard.triptakers.travel/Testing