Support » Plugin: Product Catalog » Filtering on custom field containing comma

  • Thanks for the wonderful plugin. Everything works as expected on my client’s site except for one issue. In this catalogue we have custom field values containing commas. Filtering the catalogue on these values doesn’t work, apparently because you use commas to separate multiple values in $custom_fields (Functions/Shortcodes.php:277).
    Is there a workaround you would suggest that allows us to use commas in custom field values?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor EtoileWebDesign


    Hi henkludis,

    Unfortunately, thereโ€™s no option currently to sort by a custom field value. The available front-end sorting options are name and price. But we will consider this as a feature suggestion for future updates.

    I’m sorry, I didn’t talk about sorting but about filtering. I can set a custom field value to searchable and set it’s control type to checkbox. That way I can filter the items in the catalogue. The thing is that custom field values can’t contain commas because of the way you split the search string (see my first post).

    Plugin Contributor EtoileWebDesign


    Hi henk,

    To do that, you’d have to change the separator that you mention in your first post. To do this, you’d have to modify the plugin code at the location in the file that you referenced. The explode command currently specifies the comma. You could put something else in there if you would like. It’s important to note, though, that any changes made there would be overwritten if you update the plugin.

    OK, thanks.

    Now may I suggest the following for the next version of the plugin: instead of exploding the string by comma, explode it by regex.

    I’ve written this function:

    function splitByReg($str,$pat){
    	$chunks = preg_split($pat, $str, -1, PREG_SPLIT_DELIM_CAPTURE); 
    	$items = [];
    	$item = '';
    	foreach ($chunks as $chunk){
    		if (preg_match($pat,$chunk)){
    			$item = ltrim($chunk,',');
    		} else {
    			$item .= $chunk;
    	return ($items);	

    Now instead of Shortcodes.php:277:

    $Custom_Field_IDs = explode(",", $custom_fields);

    I do:

    $pat = "/(,\d+=)/";
    $Custom_Field_IDs = splitByReg($custom_fields,$pat);

    That way there’s next to no constraints to the values custom fields can have.

    Plugin Contributor EtoileWebDesign


    Hi Henk,

    Thank you for suggestion code. We appreciate and will look in to this possibility in to the future. One other thing you can try is just use html entity (& #44 ๐Ÿ˜‰ for the comma in your custom field value name.

    hey folks,

    i have the same problem. Html entity does not work ๐Ÿ™
    Means only a dirty hack works witch is not update save!?

    Plugin Author Rustaurius


    Hi Henk,

    Thanks for the code snippet. We’re testing it internally and need to modify it slightly, but it should be included in one of the next couple of releases.



    Thanks Rustaurius,
    it looks like we still can’t use comma in our custom fields, right? Do you still have plans to include something along the lines of my code snippet above? Updating the plugin is a real pain this way…

    Plugin Contributor EtoileWebDesign


    Hi Henk,

    Thanks for following up. Unfortunately, we have not been able to implement this feature yet.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filtering on custom field containing comma’ is closed to new replies.