【发布时间】:2016-11-14 06:49:34
【问题描述】:
我正在尝试从 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
}
}
}
【问题讨论】:
标签: php wordpress woocommerce