Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Custom Taxonomies Not Saving

$
0
0

Replies: 0

I came across a bug (and a band-aid). Can you fix this in the next update? My temporary fix is somewhat crude, since I don’t want to edit the core files.

Custom Taxonomies that were previously checked on product add/manage page cannot be cleared.

Here’s what happens:
-Product Add/manage form gets generated. (OK)
-User un-checks all the checkboxes within a taxonomy (OK)
-Form gets submitted to the server.
Post data will only contain checked boxes!
-Custom Taxonomy section of form handler loops through the Taxonomies that are sent back from the form. Any taxonomies that have nothing checked will not get updated.

I see in your form handler, that you try to clear taxonomies that have no values set, however if they have no values set, then they won’t end up in the array.

My Band-Aid:
-I copied the wcfm-view-products-manage.php template to my theme folder.
-I added the following line of code underneath calls to $WCFM->library->generateTaxonomyHTML()
<input type="hidden" name="product_custom_taxonomies[<?php echo $product_taxonomy->name; ?>][]" />

Example:

<select id="<?php echo $product_taxonomy->name; ?>" name="product_custom_taxonomies[<?php echo $product_taxonomy->name; ?>][]" class="wcfm-select product_taxonomies wcfm_ele simple variable external grouped booking" multiple="multiple" data-maximum-selection-length="<?php echo $taxonomy_limit; ?>" <?php echo implode( ' ', $ptax_custom_arrtibutes ); ?> style="width: 100%; margin-bottom: 10px;">
															<?php
																$product_taxonomy_terms   = get_terms( $product_taxonomy->name, 'orderby=name&hide_empty=0&parent=0' );
																if ( $product_taxonomy_terms ) {
																	$WCFM->library->generateTaxonomyHTML( $product_taxonomy->name, $product_taxonomy_terms, $taxonomy_values_arr );
																}
															?>
                                                            <input type="hidden" name="product_custom_taxonomies[<?php echo $product_taxonomy->name; ?>][]" />
														</select>

Possible Real Fix:
Include a hidden element similar to what I added, and then unset it in the form handler loop. That would leave the value array empty for any Custom Taxonomies that have nothing checked.


Viewing all articles
Browse latest Browse all 59525

Trending Articles