Structure of postmeta meta_value for woocommerce product download

So I'm working on a monster script to port all of our existing stuff from Joomla/Virtuemart to Wordpress/WooCommerce.

So far I've got just about everything done with moving over our product categories and products, I just need to figure out the structure of the _downloadable_files postmeta.

Using this as an example:


How is the s:114 just before the file url generated? That is the only part that changes that I don't know how to generate.

Any suggestions would be greatly appreciated!

Answers 1

  • In short, this is serialized data and this is how data is stored from a custom field (and many other datastrings) in the db.

    s:114 is auto generated and simply means that the value http://localhost/wp-content/uploads/woocommerce_uploads/2014/09/test-file.pdf is a string and is 114 characters long. This is used when the data is read and used. If the URL value changes, the string length will change as the length of the string changes

    You will need to go and have a look at data serializing and unserializing

Related Questions