Quote from Rodrigo on June 30, 2022, 20:12
I needed to add support to my custom product type, and wasn't able to do so by adding the product type in a filter, so here is my suggestion:
in the file: 'classes/fixed/fixed_price.php', in the method 'woocommerce_product_options_general_product_data'
public function woocommerce_product_options_general_product_data() {
global $WOOCS;
global $post;
$_product = wc_get_product($post->ID);
add_action('admin_footer', array($this, 'admin_footer'));
if ($_product->is_type('simple') OR $_product->is_type('external') OR $_product->is_type('subscription') OR $_product->is_type('composite') OR $_product->is_type('bundle') OR $_product->is_type('box_product')) {
...
}
}
To change to:
public function woocommerce_product_options_general_product_data() {
global $WOOCS;
global $post;
$_product = wc_get_product($post->ID);
add_action('admin_footer', array($this, 'admin_footer'));
$product_types = apply_filters('woocs_product_fixed_price_data_simple_types', array('simple', 'external', 'subscription', 'composite', 'bundle', 'box_product'));
if (in_array($_product->get_type(), $product_types)) {
...
}
}
I needed to add support to my custom product type, and wasn't able to do so by adding the product type in a filter, so here is my suggestion:
in the file: 'classes/fixed/fixed_price.php', in the method 'woocommerce_product_options_general_product_data'
public function woocommerce_product_options_general_product_data() {
global $WOOCS;
global $post;
$_product = wc_get_product($post->ID);
add_action('admin_footer', array($this, 'admin_footer'));
if ($_product->is_type('simple') OR $_product->is_type('external') OR $_product->is_type('subscription') OR $_product->is_type('composite') OR $_product->is_type('bundle') OR $_product->is_type('box_product')) {
...
}
}
To change to:
public function woocommerce_product_options_general_product_data() {
global $WOOCS;
global $post;
$_product = wc_get_product($post->ID);
add_action('admin_footer', array($this, 'admin_footer'));
$product_types = apply_filters('woocs_product_fixed_price_data_simple_types', array('simple', 'external', 'subscription', 'composite', 'bundle', 'box_product'));
if (in_array($_product->get_type(), $product_types)) {
...
}
}