[API] Updated variable product attributes update for the new standard of WC 2.4
This commit is contained in:
parent
f3ac5657a4
commit
aa263ddc1e
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue