I am trying read abandoned cart details in woocommerce
from table wp_options
. The string is below format
a:19:{s:4:"cart";s:308:"a:1:{s:32:"d3d9446802a44259755d38e6d163e820";a:9:{s:10:"product_id";i:10;s:12:"variation_id";s:0:"";s:9:"variation";a:0:{}s:8:"quantity";i:1;s:10:"line_total";d:189;s:8:"line_tax";i:0;s:13:"line_subtotal";i:189;s:17:"line_subtotal_tax";i:0;s:13:"line_tax_data";a:2:{s:5:"total";a:0:{}s:8:"subtotal";a:0:{}}}}";s:15:"applied_coupons";s:6:"a:0:{}";s:23:"coupon_discount_amounts";s:6:"a:0:{}";s:27:"coupon_discount_tax_amounts";s:6:"a:0:{}";s:21:"removed_cart_contents";s:6:"a:0:{}";s:19:"cart_contents_total";d:189;s:20:"cart_contents_weight";i:2;s:19:"cart_contents_count";i:1;s:5:"total";i:0;s:8:"subtotal";i:189;s:15:"subtotal_ex_tax";i:189;s:9:"tax_total";i:0;s:5:"taxes";s:6:"a:0:{}";s:14:"shipping_taxes";s:6:"a:0:{}";s:13:"discount_cart";i:0;s:14:"shipping_total";i:0;s:18:"shipping_tax_total";i:0;s:9:"fee_total";i:0;s:4:"fees";s:6:"a:0:{}";}
How can i split this value to read the cart and product details.
Your string is serialized. You have to unserialize it. You can use a online tool for it.
http://www.unserialize.com/
Or, you can run a PHP code;
The string you are displaying is serialized. Serializing is a way of storing a PHP value (in this case an array), together with its type and structure, as a string.
You can use PHP’s
unserialize
function to transform the string back into a PHP value:This will return an array that contains a
cart
key, which is for some reason serialized as well, so you will have to useunserialize
again:Now you will be able to access the cart data.