dpa89292 2016-07-12 06:54
浏览 232

Woocommerce创建自定义变量产品类型

I'm trying to create a custom variable product type from woocommerce for a booking form, which has different pricing based on a set of variables.

I've successfully added a custom product type. But how do i duplicate the same option that the variable product has for different attribute pricing. Can't seem to find any resources related with variable product types.

// add a product type
add_filter( 'product_type_selector', 'cpt_add_custom_product_type' );
function cpt_add_custom_product_type( $types ){
    $types[ 'booking_product' ] = __( 'Booking Product' );
    return $types;
}
add_action( 'plugins_loaded', 'cpt_create_custom_product_type' );
function cpt_create_custom_product_type(){
     // declare the product class
     class WC_Product_Wdm extends WC_Product_Variable {
        public function __construct( $product ) {
           $this->product_type = 'booking_product';
           parent::__construct( $product );
           // add additional functions here
        }
    }
}
  • 写回答

2条回答 默认 最新

  • douxie5930 2016-08-07 17:15
    关注

    I've managed to get part way - by adding back in the variation and attribute tabs. Next step is to add back in "Add as a Variation" option.

    add_filter('woocommerce_product_data_tabs', function($tabs) {
    
                array_push($tabs['attribute']['class'], 'show_if_variable show_if_membership');
                array_push($tabs['variations']['class'], 'show_if_membership');
    
                return $tabs;
    
            }, 10, 1);  
    
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料