I'm trying to add extra functionality to a WordPress/WooCommerce free plugin but I got stuck. I hope I can explain properly because I am not a developer.
The plugin stores all the data (product options) in a dedicated index in wp_options table, as a serialized array.
What I want to do is to create/read/update/delete the product ID in this array based on the status of a checkbox. Something like: - if this product has this option, show a ticked checkbox - if not, add this option to this product when the checkbox is ticked - remove this option from this product when the checkbox is unticked.
But I've noticed the plugin sores it in two locations within the same array, here [conditional_rules_json] => [[[{"subject":"product","comparison":"equals","cvalue":["11","20"]}]]]]
and here
[value] => Array (
[0] => 11
[1] => 20
).
11
and 20
are the IDs of the products that are using this option now.
I don't understand how I am supposed to update the IDs based on the status of the checkbox. Am I supposed to update it in both locations or just one? And how can I do it? str_replace?
a:1:{s:29:"woo_before_add_to_cart_button";a:1:{s:6:"colour";O:26:"WEPOF_Product_Field_Select":27:{s:5:"order";i:0;s:4:"type";s:6:"select";s:2:"id";s:6:"colour";s:4:"name";s:6:"colour";s:5:"value";s:0:"";s:11:"placeholder";s:0:"";s:7:"options";a:3:{i:0;s:3:"Red";i:1;s:5:"Green";i:2;s:4:"Blue";}s:9:"validator";s:0:"";s:8:"cssclass";s:0:"";s:12:"cssclass_str";s:0:"";s:5:"title";s:0:"";s:11:"title_class";s:0:"";s:15:"title_class_str";s:0:"";s:14:"title_position";s:7:"default";s:8:"required";s:3:"yes";s:7:"enabled";s:3:"yes";s:8:"position";s:29:"woo_before_add_to_cart_button";s:22:"conditional_rules_json";s:72:"[[[[{"subject":"product","comparison":"equals","cvalue":["11","20"]}]]]]";s:17:"conditional_rules";a:1:{i:0;O:24:"WEPOF_Condition_Rule_Set":2:{s:5:"logic";s:3:"and";s:15:"condition_rules";a:1:{i:0;O:20:"WEPOF_Condition_Rule":2:{s:5:"logic";s:2:"or";s:14:"condition_sets";a:1:{i:0;O:19:"WEPOF_Condition_Set":2:{s:5:"logic";s:3:"and";s:10:"conditions";a:1:{i:0;O:15:"WEPOF_Condition":3:{s:7:"subject";s:7:"product";s:10:"comparison";s:6:"equals";s:5:"value";a:2:{i:0;s:2:"11";i:1;s:2:"20";}}}}}}}}}s:8:"name_old";s:0:"";s:12:"position_old";s:0:"";s:11:"input_class";s:0:"";s:9:"minlength";s:0:"";s:9:"maxlength";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:7:"checked";i:0;}}}