Forums › Forums › Search & Filter Pro › list separated with coma as checkboxes on post meta
- This topic has 4 replies, 2 voices, and was last updated 4 years ago by Anonymous.
-
Anonymous(Private) November 4, 2020 at 3:39 pm #265296
Hi,
I have a field name wccaf_typ_ (admin field from Filds Factory). The values of this field is enter with checkboxes and is saved in database as coma separated values eg : “cartes,rapidité,connaissances_devinettes,dessins,communication”
or
“dessins,enigmes_enquetes”
or
“cartes,bluff,prise_de_risques”
….
I want to create a search form with checkboxes for each type individualy (eg : one checkbox for “dessins” (with 2 products), one checkbox for “cartes” (with 2 products), one checkbox “communication” with one product….First I try to create automatically the form with a filter sf_input_object_pre like this :
function mon_filtre($input_object, $sfid){ if($input_object['name']=='_sfm_wccaf_typ'){ $listeOption = array(); $i = 0; $tab_types = explode(",", $types); //to get all the different checkboxes $fileds_meta = wcff()->dao->load_fields_for_product(1513, 'wccaf', 'any'); foreach ( $fileds_meta as $meta ) { if(isset($meta["wccaf_typ_"])){ $type_jeux_filed = $meta["wccaf_typ_"]; $tab_choix = explode(";",$type_jeux_filed["choices"]); foreach ( $tab_choix as $choix ) { $val_label=explode("|",$choix); foreach ( $tab_types as $tab_type ) { //WHAT TO DO HERE TO CREATE A NEW OPTION FIELD $listeOption[$i]->label = $val_label[0]; $listeOption[$i]->value = $val_label[1]; $i++; } } } } $input_object['options']= $listeOption; } return $input_object; } add_filter('sf_input_object_pre', 'mon_filtre', 10, 2);
And then I want to filter my product with this checkboxes and I dont know how can I do.
Thanks for your help.
Best regards
Trevor(Private) November 5, 2020 at 8:19 am #265318The problem is that the data is not stored in the post meta table field as correctly serialized data (in the normal WordPress format), so, our cache building code sees it as one big term, rather than separate terms.
This post asked a similar question:
The sf_input_object_pre filter could only work if the values had been cached separately (in fact, chances are you would not have needed your code at all).
-
AuthorPosts