[API] Updated variable product attributes update for the new standard of WC 2.4

This commit is contained in:
Claudio Sanches 2015-07-22 21:07:05 -03:00
parent f3ac5657a4
commit aa263ddc1e
2 changed files with 20 additions and 8 deletions

View File

@ -1467,11 +1467,17 @@ class WC_API_Products extends WC_API_Resource {
}
if ( isset( $_attribute['is_variation'] ) && $_attribute['is_variation'] ) {
$attribute_key = 'attribute_' . sanitize_title( $_attribute['name'] );
$attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : '';
$updated_attribute_keys[] = $attribute_key;
$_attribute_key = 'attribute_' . sanitize_title( $_attribute['name'] );
$updated_attribute_keys[] = $_attribute_key;
update_post_meta( $variation_id, $attribute_key, $attribute_value );
if ( isset( $_attribute['is_taxonomy'] ) && $_attribute['is_taxonomy'] ) {
// Don't use wc_clean as it destroys sanitized characters
$_attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : '';
} else {
$_attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
}
update_post_meta( $variation_id, $_attribute_key, $_attribute_value );
}
}

View File

@ -1467,11 +1467,17 @@ class WC_API_Products extends WC_API_Resource {
}
if ( isset( $_attribute['is_variation'] ) && $_attribute['is_variation'] ) {
$attribute_key = 'attribute_' . sanitize_title( $_attribute['name'] );
$attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : '';
$updated_attribute_keys[] = $attribute_key;
$_attribute_key = 'attribute_' . sanitize_title( $_attribute['name'] );
$updated_attribute_keys[] = $_attribute_key;
update_post_meta( $variation_id, $attribute_key, $attribute_value );
if ( isset( $_attribute['is_taxonomy'] ) && $_attribute['is_taxonomy'] ) {
// Don't use wc_clean as it destroys sanitized characters
$_attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : '';
} else {
$_attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
}
update_post_meta( $variation_id, $_attribute_key, $_attribute_value );
}
}