Tom. Posted October 17, 2018 Share Posted October 17, 2018 I'm having a strange issue here where my selector is case sensitive on a default install with no modification MySQL. The selector is as follows: $vars = explode("?", $_SERVER[REQUEST_URI])[1]; $selector = implode(", ", explode("&", $vars)); echo $selector; $variation = $page->wc_variations->get("wc_variation_value='$selector'"); This doesn't work `$selector` outputs `size=14, colour=blue` If I was to change the value given to `Size=14, Colour=Blue` it then finds the repeater item. Anyone else come across this issue before? EDIT: Seems like there is an inconsistency between database searches and in memory searches. I've just done an extra: foreach($page->wc_variations as $variation) $variation->wc_variation_value = strtolower($variation->wc_variation_value); Before doing the selector. Not great, but it works. 1 Link to comment Share on other sites More sharing options...
kongondo Posted October 17, 2018 Share Posted October 17, 2018 14 minutes ago, Tom. said: EDIT: Seems like there is an inconsistency between database searches and in memory searches. There is. I've found that *= in in-memory searches works irrespective of case (IIRC). 1 Link to comment Share on other sites More sharing options...
Tom. Posted October 17, 2018 Author Share Posted October 17, 2018 2 minutes ago, kongondo said: There is. I've found that *= in in-memory searches works irrespective of case (IIRC). Worked a charm - thanks! EDIT: Spoke to soon, in this case it must be = because if you have an empty selector that means that product variation doesn't exist. So selecting colour=blue isn't enough, but *= will still make a selection. Link to comment Share on other sites More sharing options...
kongondo Posted October 17, 2018 Share Posted October 17, 2018 (edited) In such cases, I always lcfirst() my properties and also make sure to remove any spaces. $key = lcfirst($sanitizer->fieldName($key));// "Size" to "size" OR "some key" to "some_key" Edited October 17, 2018 by kongondo 1 Link to comment Share on other sites More sharing options...
kixe Posted October 17, 2018 Share Posted October 17, 2018 Maybe related: $page->children->sort('title') // case sensitive sort $page->children('sort=title') // case insensitive sort Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now