[API] Fixed errors when the description and short_description is empty in products endpoint

This commit is contained in:
Claudio Sanches 2015-01-19 10:52:44 -02:00
parent 85df97ffb5
commit b6925d49ef
1 changed files with 10 additions and 4 deletions

View File

@ -207,11 +207,17 @@ class WC_API_Products extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_product_type', sprintf( __( 'Invalid product type - the product type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_product_types() ) ) ), 400 );
}
// enable description html tags.
$post_content = ( isset( $data['enable_html_description'] ) && 'true' === $data['enable_html_description'] ) ? $data['description'] : wc_clean( $data['description'] );
// Enable description html tags.
$post_content = isset( $data['description'] ) ? wc_clean( $data['description'] ) : '';
if ( $post_content && isset( $data['enable_html_description'] ) && 'true' === $data['enable_html_description'] ) {
$post_content = $data['description'];
}
// enable short description html tags.
$post_excerpt = ( isset( $data['enable_html_short_description'] ) && 'true' === $data['enable_html_short_description'] ) ? $data['short_description'] : wc_clean( $data['short_description'] );
// Enable short description html tags.
$post_excerpt = isset( $data['short_description'] ) ? wc_clean( $data['short_description'] ) : '';
if ( $post_excerpt && isset( $data['enable_html_short_description'] ) && 'true' === $data['enable_html_short_description'] ) {
$post_excerpt = $data['short_description'];
}
$new_product = array(
'post_title' => wc_clean( $data['title'] ),