I am new to Wordpress and Woocommerce. Looking at the database I came to see few text columns where the stored value looks something like this:
a:23:s:16:"woofc_last_added";s:32:"d770c2ff0c2b832aad82b0cbc3f144a6";s:21:"removed_cart_contents";s:6:"a:0:{}";s:10:"wc_notices";N;s:8:"customer";s:775:"a:25:}
I have stripped most of the fields, but it looks somewhat like this.
What format is this?
How can I parse values in this format?
How can I retrieve all the values from this text data in php?
The data is in a serialized protected format
You will need to use instead
WC_Session_Handler
orWC_Session
available methods.1) To get the current customer
WC_Session_Handler
object you can use:2) To get the
WC_Session_Handler
object from a defined customer ID3) Accessing the protected data:
It stores in serialized format. You can get normal array by using unserialized function.
unserialize()
Its not a JSON format it is simple a way wordpress save arrays in serialized format in its tables. Just use php unserialized function, it will unserialize this and you will be able to parse it in normal php array format. You can view this function documentation here http://php.net/manual/en/function.unserialize.php