The data structure we can find in WooCommerce options table is a serialized array.
Serialized data is used to store complex data structures like arrays and objects as a single string in the database. This makes it easier to save and retrieve structured data in PHP, which is what WordPress and WooCommerce are built on.
a:33:{s:14:”wholesale_role”;s:6:”single”;s:31:”default_multipe_wholesale_roles”;s:0:””;s:17:”disable_auto_role”;s:3:”yes”;s:24:”enable_registration_page”;s:3:”yes”;s:17:”registration_page”;s:3:”778″;s:17:”register_redirect”;s:4:”1477″;s:23:”wwp_attachment_location”;s:0:””;s:21:”email_user_role_value”;s:0:””;s:24:”order_custom_email_value”;s:0:””;s:27:”enable_admin_new_order_item”;s:3:”yes”;s:13:”enable_coupon”;s:3:”yes”;s:24:”request_for_sample_label”;s:0:””;s:43:”wwp_select_wholesale_role_for_non_logged_in”;s:2:”-1″;s:32:”wwp_custom_message_non_logged_in”;s:0:””;s:12:”tier_pricing”;a:1:{i:50;a:1:{s:10:”e1172e569b”;a:3:{s:3:”min”;s:0:””;s:3:”max”;s:0:””;s:5:”price”;s:0:””;}}}s:14:”retailer_label”;s:0:””;s:17:”retailer_disabled”;s:3:”yes”;s:16:”wholesaler_label”;s:9:”dimosvamv”;s:10:”save_label”;s:0:””;s:19:”save_price_disabled”;s:3:”yes”;s:17:”display_link_text”;s:0:””;s:26:”login_message_waiting_user”;s:64:”You can not access this store, Your request status is in Pending”;s:27:”login_message_rejected_user”;s:64:”You can not access this store, Your request is Rejected by admin”;s:29:”restrict_store_access_message”;s:0:””;s:14:”enable_upgrade”;s:3:”yes”;s:16:”upgrade_tab_text”;s:21:”Upgrade to Wholesaler”;s:13:”wholesale_css”;s:32:”/* Enter Your Custom CSS Here */”;s:28:”wholesaler_allow_minimum_qty”;s:2:”no”;s:21:”restrict_store_access”;s:2:”no”;s:25:”over_right_wholesale_form”;s:2:”no”;s:23:”wholesaler_prodcut_only”;s:2:”no”;s:27:”enable_strike_through_price”;s:2:”no”;s:19:”payment_method_name”;a:0:{}}
Breaking Down the Example:
a:33:{
a
means it’s an array.33
means it contains 33 key-value pairs.
Example Key-Value Pair:
s:14:"wholesale_role";s:6:"single";
s:14
— The key is a string of 14 characters (wholesale_role
).s:6
— The value is a string of 6 characters (single
).
Nested Array Example:
s:12:"tier_pricing";a:1:{
i:50;a:1:{
s:10:"e1172e569b";a:3:{
s:3:"min";s:0:"";
s:3:"max";s:0:"";
s:5:"price";s:0:"";
}
}
}
tier_pricing
— This key has an array (denoted bya
) as its value.- Inside this, there is an indexed array (
i:50
), which itself contains another array with keys likemin
,max
, andprice
.
Purpose:
This serialized data structure is commonly used by plugins and themes in WordPress to:
- Store settings and configuration options.
- Save nested or hierarchical data (arrays/objects).
- Maintain complex relationships between settings.
How to Work with This Data:
- Deserialize (PHP):
$data = unserialize('a:33:{s:14:"wholesale_role";s:6:"single"; ... }'); print_r($data);
- Modify Values: Update values within the array and serialize it back:
$data['wholesale_role'] = 'multi'; $new_data = serialize($data);
- Update in Database (WordPress):
update_option('plugin_option_name', $new_data);
Tools to View/Modify Serialized Data:
- Use online tools like www.unserialize.com.
- Plugins such as WP Data Access or Adminer for database management.