Suggestion to filter plugin options
-
Hi Sarawana.
Greatly enjoy your plugin as it’s robust and has lots of actions.
However it seems you sort of left out the filters ??I’m in the situation where on some products we want to clone the fields and on some not.
This can be solved by passing the retrieved options through a filter in the plugin.I simply changed line 41 in
wc-fields-factory/classes/wcff-product-form.php
to$wccpf_options = apply_filters( 'wcff/load/options', get_option( 'wccpf_options' ), $product );
And then I can in my own plugin do something like:
/** * Change the behaviour of WC Fields Factory depending on the product * * @since 1.0.0 */ public function fields_factory_settings( $options, $product ){ if( $product->id == 98 ){ $options['fields_cloning'] = 'no'; } return $options; }
If you could implement these changes to the plugin so it’s not overwritten next time we update that would be awesome!
There’s one more issue with this tho. Since you fetch the options on many different places we’d have to add this filter to each place. Of course that could be done but it’d be a nicer solution if you break out the fetching of the options into it’s own function (maybe even a class for get/set of the options). That way you could just apply the filter once and it’s all good!
Let me know what you think ??
P.S. I’d be happy to share the code with you but I can’t seem to find any github repo or the like? That way I could do a pull request. D.S
- The topic ‘Suggestion to filter plugin options’ is closed to new replies.