默认情况,WooCommerce的产品类型有:Simple, Variable, Grouped and External 这四种;在实际应用中,我们可能需要创建新的产品类型:Simple, Variable, Grouped and External 这四种。
在实际应用中,我们可能需要创建新的产品类型: function fjj_add_custom_product_type( $types ){ {.
function fjj_add_custom_product_type( $types ){ $types[ 'custom' ] = 'Custom product'; return $types; } add_filter( 'product_type_selector', 'fjj_add_custom_product_type' ); 函数 fjj_create_custom_product_type(){ 类 WC_Product_Custom 扩展 WC_Product { 公共函数 get_type() { return 'custom'; } } } add_action( 'init', 'fjj_create_custom_product_type' ); 函数 fjj_woocommerce_product_class( $classname, $product_type ) { 如果 ( $product_type == 'custom' ) { $classname = 'WC_Product_Custom'; } 返回 $classname; } add_filter( 'woocommerce_product_class', 'fjj_woocommerce_product_class', 10, 2 );
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)