Hello, there,
I had a look at your site and what was thinking that will work – won’t.
As your options fields have different names but some times shares the same value (url) I can’t find which was the selected on in the back end so I have to do this in the front end.
I have wrote a small piece of javascript and have test it on your site and it works well, but as this is quite a custom thing I can’t implement it in my plugin and I don’t recommend to paste it there as well as I might update the plugin and this changes will be lost. So what i advise is to add the piece of code in you theme’s js file (something like custom.js or frontedn.js).
Here is the code itself:
(function($){
var currentUrl = window.location.href;
var lastUrl = sessionStorage.getItem('last-option-url');
var lastCountry = sessionStorage.getItem('last-option-name');
console.log(lastCountry);
console.log(lastUrl);
if (lastUrl !== null && lastCountry !== null && lastUrl == currentUrl) {
//select the option by name of the country
$('.dms-select option:contains("'+lastCountry+'")').prop('selected','selected');
sessionStorage.removeItem('last-option-name');
sessionStorage.removeItem('last-option-url');
}
$(".dms-select").on('change', function(){
var name = $('option:selected', this).text();
var url = $(this).val() ;
//store the data in session so we can check the selected option after the redirect
sessionStorage.setItem('last-option-name', name);
sessionStorage.setItem('last-option-url', url);
})
})(jQuery);
Please do let me know when you get it on your page and is it working correctly,
Cheers,
Al