mar*_*rk5 4 php wordpress woocommerce
我正在尝试从 woocommerce 为预订表单创建自定义变量产品类型,该类型根据一组变量具有不同的定价。
我已成功添加自定义产品类型。但是我如何复制可变产品对于不同属性定价的相同选项。似乎找不到与可变产品类型相关的任何资源。
// 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
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
    小智 5
我已经成功地通过添加回变体和属性选项卡来完成任务。下一步是添加回“添加为变体”选项。
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);  
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           3706 次  |  
        
|   最近记录:  |