diff --git a/includes/wc-functions.php b/includes/wc-functions.php index 6c90175829..5f4751c0ce 100755 --- a/includes/wc-functions.php +++ b/includes/wc-functions.php @@ -33,6 +33,7 @@ function dokan_process_product_meta( $post_id ) { // Set visibiliy for WC 3.0.0+ $terms = array(); + switch ( $_POST['_visibility'] ) { case 'hidden' : $terms[] = 'exclude-from-search'; @@ -46,6 +47,14 @@ function dokan_process_product_meta( $post_id ) { break; } + $product_visibility = get_the_terms( $post_id, 'product_visibility' ); + $term_names = is_array( $product_visibility ) ? wp_list_pluck( $product_visibility, 'name' ) : array(); + $featured = in_array( 'featured', $term_names, true ); + + if ( $featured ) { + $terms[] = 'featured'; + } + wp_set_post_terms( $post_id, $terms, 'product_visibility', false ); update_post_meta( $post_id, '_visibility', stripslashes( $_POST['_visibility'] ) );