【发布时间】:2018-03-17 13:20:18
【问题描述】:
在 Woocommerce 中,我创建了一个自定义产品类型 live_stream。
但是,当我在此自定义类型中创建新产品并发布它时,该产品仍然是“简单产品”,并且没有为其设置 live_stream 自定义类型。
我做错了什么?如何使该自定义产品类型发挥作用?
这是我的代码
function wpstream_register_live_stream_product_type() {
class Wpstream_Product_Live_Stream extends WC_Product {
public function __construct( $product ) {
$this->product_type = 'live_stream';
parent::__construct( $product );
}
public function get_type() {
return 'live_stream';
}
}
}
add_action( 'init', 'wpstream_register_live_stream_product_type' );
function wpstream_add_products( $types ){
$types[ 'live_stream' ] = __( 'Live Channel','wpestream' );
return $types;
}
add_filter( 'product_type_selector', 'wpstream_add_products' );
【问题讨论】:
标签: php wordpress class woocommerce product