我正在尝试从 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
}
}
}
最佳答案
我已经设法做到了 - 通过在变体和属性选项卡中重新添加。下一步是重新添加“作为变体添加”选项。
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);
关于php - Woocommerce 创建自定义变量产品类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38321915/