From 97b6ade253ead61a44dc9275bd5577f968fcb0be Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Sat, 1 Oct 2011 23:21:44 +0100 Subject: [PATCH] Removing attributes fix. Closes #34. --- admin/writepanels/writepanel-product_data.php | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/admin/writepanels/writepanel-product_data.php b/admin/writepanels/writepanel-product_data.php index 44fcf40a349..53250315d56 100644 --- a/admin/writepanels/writepanel-product_data.php +++ b/admin/writepanels/writepanel-product_data.php @@ -419,21 +419,26 @@ function woocommerce_process_product_meta( $post_id, $post ) { $values = explode('|', $values); $values = array_map('trim', $values); endif; + + // Remove empty items in the array + $values = array_filter( $values ); // Update post terms if (taxonomy_exists( $attribute_names[$i] )) : wp_set_object_terms( $post_id, $values, $attribute_names[$i] ); endif; - - // Add attribute to array, but don't set values - $attributes[ sanitize_title( $attribute_names[$i] ) ] = array( - 'name' => htmlspecialchars(stripslashes($attribute_names[$i])), - 'value' => '', - 'position' => $attribute_position[$i], - 'is_visible' => $is_visible, - 'is_variation' => $is_variation, - 'is_taxonomy' => $is_taxonomy - ); + + if ($values) : + // Add attribute to array, but don't set values + $attributes[ sanitize_title( $attribute_names[$i] ) ] = array( + 'name' => htmlspecialchars(stripslashes($attribute_names[$i])), + 'value' => '', + 'position' => $attribute_position[$i], + 'is_visible' => $is_visible, + 'is_variation' => $is_variation, + 'is_taxonomy' => $is_taxonomy + ); + endif; else : // Format values $values = htmlspecialchars(stripslashes($attribute_values[$i]));