Today I ran into a little issue with a Woocommerce extension called Customer/Order CSV Export. Whenever a custom field name ended with a question mark, the export wouldn’t return the results for that field/column. I looked into it and the problem was with some extra spaces that were for some  reason (anyone know why?) added to the beginning of the value in the array.

Here is what I did to fix it from line 295 in the main plugin file:

foreach ($extra_data_fields as $key => $value) {
	$fixed_value = $woo_order->order_custom_fields[$value]['0'];
	if (strpos($value, '?') !== false) { 
		$fixed_value = substr($fixed_value, 2);
	}
	$order_extra[ $key ] = isset($woo_order->order_custom_fields[$value]) ? $fixed_value : '';
}

One thing I couldn’t figure out was the cause of the extra spaces from the question mark. Anyone know what could be causing that?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.