delete( $wpdb->woocommerce_termmeta, array( 'woocommerce_term_id' => $term_id ), array( '%d' ) ); } } /** * Category thumbnail fields. */ public function add_category_fields() { ?>
term_id, 'display_type', true ); $thumbnail_id = absint( get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) ); if ( $thumbnail_id ) { $image = wp_get_attachment_thumb_url( $thumbnail_id ); } else { $image = wc_placeholder_img_src(); } ?>

Note: Deleting a term will remove it from all products and variations to which it has been assigned. Recreating a term will not automatically assign it back to products.', 'woocommerce' ) ); } /** * Thumbnail column added to category admin. * * @param mixed $columns * @return array */ public function product_cat_columns( $columns ) { $new_columns = array(); $new_columns['cb'] = $columns['cb']; $new_columns['thumb'] = __( 'Image', 'woocommerce' ); unset( $columns['cb'] ); return array_merge( $new_columns, $columns ); } /** * Thumbnail column value added to category admin. * * @param string $columns * @param string $column * @param int $id * @return array */ public function product_cat_column( $columns, $column, $id ) { if ( 'thumb' == $column ) { $thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = wp_get_attachment_thumb_url( $thumbnail_id ); } else { $image = wc_placeholder_img_src(); } // Prevent esc_url from breaking spaces in urls for image embeds // Ref: http://core.trac.wordpress.org/ticket/23605 $image = str_replace( ' ', '%20', $image ); $columns .= '' . esc_attr__( 'Thumbnail', 'woocommerce' ) . ''; } return $columns; } /** * Maintain term hierarchy when editing a product. * * @param array $args * @return array */ public function disable_checked_ontop( $args ) { if ( 'product_cat' == $args['taxonomy'] ) { $args['checked_ontop'] = false; } return $args; } } new WC_Admin_Taxonomies();