Skip to content

Commit

Permalink
fix: save featured product (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
saimonh3 authored and sabbir1991 committed Nov 26, 2018
1 parent 4dbe881 commit 048b100
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions includes/wc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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'] ) );

Expand Down

0 comments on commit 048b100

Please sign in to comment.