WC_Admin_Taxonomies::product_cat_column()publicWC 1.0

Thumbnail column value added to category admin.

Method of the class: WC_Admin_Taxonomies{}

No Hooks.

Return

String.

Usage

$WC_Admin_Taxonomies = new WC_Admin_Taxonomies();
$WC_Admin_Taxonomies->product_cat_column( $columns, $column, $id );
$columns(string) (required)
Column HTML output.
$column(string) (required)
Column name.
$id(int) (required)
Product ID.

WC_Admin_Taxonomies::product_cat_column() code WC 8.7.0

public function product_cat_column( $columns, $column, $id ) {
	if ( 'thumb' === $column ) {
		// Prepend tooltip for default category.
		$default_category_id = absint( get_option( 'default_product_cat', 0 ) );

		if ( $default_category_id === $id ) {
			$columns .= wc_help_tip( __( 'This is the default category and it cannot be deleted. It will be automatically assigned to products with no category.', 'woocommerce' ) );
		}

		$thumbnail_id = get_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: https://core.trac.wordpress.org/ticket/23605 .
		$image    = str_replace( ' ', '%20', $image );
		$columns .= '<img src="' . esc_url( $image ) . '" alt="' . esc_attr__( 'Thumbnail', 'woocommerce' ) . '" class="wp-post-image" height="48" width="48" />';
	}
	if ( 'handle' === $column ) {
		$columns .= '<input type="hidden" name="term_id" value="' . esc_attr( $id ) . '" />';
	}
	return $columns;
}