WooCommerce:관리 제품 목록에서 제품명 옆에 제품 유형을 추가하는 방법
새 제품 유형을 생성했습니다.Crush Video Product". 사용자 정의 탭에서 모든 메타 필드를 올바르게 저장하고 있습니다.
// add a product type
add_filter( 'product_type_selector', 'crush_add_custom_product_type' );
function crush_add_custom_product_type( $types ){
$types[ 'crush_video_product' ] = __( 'Group Video Class' );
return $types;
}
// Initiate Class when plugin is loaded
add_action( 'plugins_loaded', 'crush_create_custom_product_type' );
function crush_create_custom_product_type(){
// declare the product class
class WC_Product_Crush_Video_Product extends WC_Product{
public function __construct( $product ) {
$this->product_type = 'crush_video_product';
parent::__construct( $product );
// add additional functions here
}
// Needed since Woocommerce version 3
public function get_type() {
return 'crush_video_product';
}
}
}
모든 제품을 볼 수 있는 관리 영역에서 제품명 뒤에 제품 종류 이름이 적혀있는 플러그인을 본 적이 있습니다.
많이 찾아봤지만 이렇게 할 수 있는 갈고리를 찾을 수가 없었습니다.
- 렌더 열: 이름.
좀 더 적합한 후크가 없는 것 같아요, 그래서 한 가지 방법은,manage_product_posts_custom_column디스플레이에 필요한 CSS가 필요한 경우
function action_manage_product_posts_custom_column( $column, $postid ) {
if ( $column == 'name' ) {
// Get product
$product = wc_get_product( $postid );
// Get type
$product_type = $product->get_type();
// Output
echo ' <span>– ' . ucfirst( $product_type ) . '</span>';
}
}
add_action( 'manage_product_posts_custom_column', 'action_manage_product_posts_custom_column', 20, 2 );
결과:
언급URL : https://stackoverflow.com/questions/62301223/woocommerce-how-to-add-product-type-next-to-product-name-in-admin-product-list
'source' 카테고리의 다른 글
| jQuery로 마지막 5개 요소 선택 (0) | 2023.09.17 |
|---|---|
| 데이터베이스 설계: 부울 열을 타임스탬프 열로 바꿉니다. (0) | 2023.09.17 |
| OpenXML을 사용하여 병합 셀 만들기 (0) | 2023.09.17 |
| mysql에서 외부 키의 이름을 변경하려면 어떻게 해야 합니까? (0) | 2023.09.17 |
| mysql_connect(): 헤더 및 클라이언트 라이브러리 마이너 버전 불일치 라이브러리:100005 (0) | 2023.09.17 |

