WC_Admin_List_Table_Products::add_sample_product_badge()publicWC 8.8.0

Add a sample product badge to the product list table.

Method of the class: WC_Admin_List_Table_Products{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Admin_List_Table_Products = new WC_Admin_List_Table_Products();
$WC_Admin_List_Table_Products->add_sample_product_badge( $column_name, $post_id );
$column_name(string) (required)
Column name.
$post_id(int) (required)
Post ID.

Changelog

Since 8.8.0 Introduced.

WC_Admin_List_Table_Products::add_sample_product_badge() code WC 9.7.1

public function add_sample_product_badge( $column_name, $post_id ) {
	$is_sample_product = 'product' === get_post_type( $post_id ) && get_post_meta( $post_id, '_headstart_post', true );

	if ( $is_sample_product && 'name' === $column_name ) {
		echo '<span class="sample-product-badge" style="margin-right: 6px;border-radius: 4px; background: #F6F7F7; padding: 4px; color: #3C434A;font-size: 12px;font-style: normal;font-weight: 400;line-height: 16px; height: 24px;">' . esc_html__( 'Sample', 'woocommerce' ) . '</span>';
	}
}