I am currently building a Wordpress plugin to fulfil WooCommerce orders for a "virtual" product. Once the payment is confirmed, I make an API call that returns a large (~50 values) array of technical data about a vehicle. This is then stored as meta data for the order, so it can be displayed to the customer and also retrieved at a later date.
I have read lots to suggest that serializing meta data and storing it as a single field is a bad idea, and makes life difficult in the long run. But it makes much more sense to me in this case to serialize the data - optimising performance and reducing the number of DB entries by 50x. I don't need to query by the contents of the data, it is just a self-contained data object, if you will, that will always be accessed in its entirety.
$response = wp_remote_get($endpoint); $body = wp_remote_retrieve_body($response); $obj = json_decode($body, true); $data = $obj["Response"]["Payload"]; // Array of ~50 strings update_post_meta($order, 'vehicle_data', $data);
Can somebody reassure me that this is sensible, as I'm now worried from all I've read that this may trip me up later.