Improve save_attributes ajax function to correctly save text attributes.
Closes #7832
This commit is contained in:
parent
12dde04e16
commit
36a49f87c2
|
@ -607,9 +607,23 @@ class WC_AJAX {
|
|||
if ( is_array( $attribute_values[ $i ] ) ) {
|
||||
$values = array_map( 'sanitize_title', $attribute_values[ $i ] );
|
||||
|
||||
// Text based attributes - Posted values are term names - don't change to slugs
|
||||
// Text based attributes - Posted values are term names, wp_set_object_terms wants ids or slugs.
|
||||
} else {
|
||||
$values = array_map( 'stripslashes', array_map( 'strip_tags', explode( WC_DELIMITER, $attribute_values[ $i ] ) ) );
|
||||
$values = array();
|
||||
$raw_values = array_map( 'stripslashes', array_map( 'strip_tags', explode( WC_DELIMITER, $attribute_values[ $i ] ) ) );
|
||||
|
||||
foreach ( $raw_values as $value ) {
|
||||
$term = get_term_by( 'name', $value, $attribute_names[ $i ] );
|
||||
if ( ! $term ) {
|
||||
$term = wp_insert_term( $value, $attribute_names[ $i ] );
|
||||
|
||||
if ( $term && ! is_wp_error( $term ) ) {
|
||||
$values[] = $term['term_id'];
|
||||
}
|
||||
} else {
|
||||
$values[] = $term->term_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove empty items in the array
|
||||
|
|
|
@ -141,6 +141,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Feature - Show full category hierarchy in permalinks.
|
||||
* Fix - Ensure coupon taxes are reset when calculating totals.
|
||||
* Fix - Improve discount amount rounding.
|
||||
* Tweak - Improve save_attributes ajax function to correctly save text attributes.
|
||||
* Tweak - Base discounts on the undiscounted price. #5874
|
||||
* Tweak - Added wc_product_cat_class functions.
|
||||
|
||||
|
|
Loading…
Reference in New Issue