Programmatically change value of settings
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from Sylvain on August 21, 2023, 15:22Hello,
I have read a lot of internet page about my problem but can not fix it :
In wp-admin, when I go to the menu Woocommerce -> settings -> Product filter, I can see all existing attributes I have created but by default :
- the type is "Radio"
- the attribute is not selected so it is not display
- the settings "Show title label" in attribute parameters window is set to false.
As I have a lot of attributes, my question is : how can I programmatically customise settings set in WooCommerce -> Products Filter -> Structure
Thank you for your answer.
Regards,
Hello,
I have read a lot of internet page about my problem but can not fix it :
In wp-admin, when I go to the menu Woocommerce -> settings -> Product filter, I can see all existing attributes I have created but by default :
- the type is"Radio"
- the attribute is not selected so it is not display
- the settings"Show title label" in attribute parameters window is set to false.
As I have a lot of attributes, my question is : how can I programmatically customise settings set in WooCommerce -> Products Filter -> Structure
Thank you for your answer.
Regards,
Quote from Pablo Borysenco on August 22, 2023, 11:46Hello
Please read this - https://products-filter.com/lot-taxonomies-settings-page-save-options-doesn-works
To change settings in code you can use this variable
woof()->settings
Hello
Please read this - https://products-filter.com/lot-taxonomies-settings-page-save-options-doesn-works
To change settings in code you can use this variable
woof()->settings
Quote from Sylvain on August 23, 2023, 16:26Thank you for your answer but I am still stuck.
This settings is global to woof plugins. Is it possible to programmatically set type "dropdown" instead of "Radio" for one taxonomy ? or set "Show title label" to true for a specific taxonomy ?
In other hand I can not call woof() method as it is not loaded : i got "Uncaught Error: Call to undefined function woof()" : which file should i load ?
Thank you for your answer but I am still stuck.
This settings is global to woof plugins. Is it possible to programmatically set type"dropdown" instead of"Radio" for one taxonomy ? or set"Show title label" to true for a specific taxonomy ?
In other hand I can not call woof() method as it is not loaded : i got"Uncaught Error: Call to undefined function woof()" : which file should i load ?
Quote from Sylvain on August 23, 2023, 17:20Hello : I 've made a step, but did not find a solution.
To answer my own question :
- The woof()->settings contains all taxonomy.
- I can load the plugin file so WOOF is defined.
I execute this code to change tye taxonomy pa_ef000001 form type radio to type checkbox
require_once(ABSPATH . '/wp-content/plugins/woocommerce-products-filter/index.php'); $WOOF = new WOOF(); $WOOF->settings['tax_type']['pa_ef000001'] = 'checkbox'; error_log(json_encode($WOOF->settings));But my change is not saved : if I go back in wp-admin interface my taxonomy 'pa_ef000001' is always of type radio.
Thank you for your help
Hello : I 've made a step, but did not find a solution.
To answer my own question :
- The woof()->settings contains all taxonomy.
- I can load the plugin file so WOOF is defined.
I execute this code to change tye taxonomy pa_ef000001 form type radio to type checkbox
require_once(ABSPATH . '/wp-content/plugins/woocommerce-products-filter/index.php'); $WOOF = new WOOF(); $WOOF->settings['tax_type']['pa_ef000001'] = 'checkbox'; error_log(json_encode($WOOF->settings));
But my change is not saved : if I go back in wp-admin interface my taxonomy 'pa_ef000001' is always of type radio.
Thank you for your help
Quote from Pablo Borysenco on August 24, 2023, 10:19Hello
Yes, it will not work because you changed the settings in your object
In other hand I can not call woof() method as it is not loaded - Ok! This may mean that you call the method very early (before the object is created). Try using hooks. An example:
add_action('init', function(){
woof()->settings['tax_type']['pa_ef000001'] = 'checkbox';
}, 9999);
Hello
Yes, it will not work because you changed the settings in your object
In other hand I can not call woof() method as it is not loaded - Ok! This may mean that you call the method very early (before the object is created). Try using hooks. An example:
add_action('init', function(){
woof()->settings['tax_type']['pa_ef000001'] = 'checkbox';
}, 9999);
Quote from Sylvain on August 24, 2023, 15:26Hello,
Here is my working solution :
// import required file from plugin woof require_once(WP_PLUGIN_DIR . '/woocommerce-products-filter/index.php'); $attribute = "SLUG_OF_ATTRIBUTE_TO_UPDATE"; $WOOF = new WOOF(); // Change type $WOOF->settings['tax_type']['pa_'.$attribute] = 'checkbox'; // save options update_option('woof_settings', $WOOF->settings);
Hello,
Here is my working solution :
// import required file from plugin woof require_once(WP_PLUGIN_DIR . '/woocommerce-products-filter/index.php'); $attribute ="SLUG_OF_ATTRIBUTE_TO_UPDATE"; $WOOF = new WOOF(); // Change type $WOOF->settings['tax_type']['pa_'.$attribute] = 'checkbox'; // save options update_option('woof_settings', $WOOF->settings);
Quote from Pablo Borysenco on August 25, 2023, 09:49Hello
Great! Thank you for your cooperation
Hello
Great! Thank you for your cooperation