PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

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 please
If 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.

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,

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

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 ?

 

Hello : I 've made a step, but did not find a solution.

To answer my own question :

  1. The woof()->settings contains all taxonomy.
  2. 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

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,

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

Great! Thank you  for  your  cooperation