From f741d507ba818f13b202dddcdbed7ade124725a3 Mon Sep 17 00:00:00 2001 From: Naveen giri <1naveengiri@gmail.com> Date: Fri, 22 Feb 2019 19:13:35 +0530 Subject: [PATCH] Bugfix/#22821: Add Fix for Warning and Notices on save attribute button click --- includes/class-wc-ajax.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 2ba970ab370..086a381f9e6 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -632,21 +632,22 @@ class WC_AJAX { ob_start(); $attributes = $product->get_attributes( 'edit' ); $i = -1; + if( isset( $data['attribute_names'] ) && !empty( $data['attribute_names'] ) ){ + foreach ( $data['attribute_names'] as $attribute_name ) { + $attribute = isset( $attributes[ sanitize_title( $attribute_name ) ] ) ? $attributes[ sanitize_title( $attribute_name ) ] : false; + if ( ! $attribute ) { + continue; + } + $i++; + $metabox_class = array(); - foreach ( $data['attribute_names'] as $attribute_name ) { - $attribute = isset( $attributes[ sanitize_title( $attribute_name ) ] ) ? $attributes[ sanitize_title( $attribute_name ) ] : false; - if ( ! $attribute ) { - continue; + if ( $attribute->is_taxonomy() ) { + $metabox_class[] = 'taxonomy'; + $metabox_class[] = $attribute->get_name(); + } + + include( 'admin/meta-boxes/views/html-product-attribute.php' ); } - $i++; - $metabox_class = array(); - - if ( $attribute->is_taxonomy() ) { - $metabox_class[] = 'taxonomy'; - $metabox_class[] = $attribute->get_name(); - } - - include( 'admin/meta-boxes/views/html-product-attribute.php' ); } $response['html'] = ob_get_clean();