30 年 2022 月 20 日 12:XNUMX の Rodrigo からの引用
カスタム製品タイプにサポートを追加する必要がありましたが、フィルターに製品タイプを追加することでそれを行うことができなかったので、ここに私の提案があります:
ファイル:「classes/fixed/fixed_price.php」、メソッド「woocommerce_product_options_general_product_data」
public function woocommerce_product_options_general_product_data() { グローバル $WOOCS; グローバル $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')) { ... } }
次のように変更するには:
public function woocommerce_product_options_general_product_data() { グローバル $WOOCS; グローバル $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)) { ... } }
カスタム製品タイプにサポートを追加する必要がありましたが、フィルターに製品タイプを追加することでそれを行うことができなかったので、ここに私の提案があります:
ファイル:「classes/fixed/fixed_price.php」、メソッド「woocommerce_product_options_general_product_data」
public function woocommerce_product_options_general_product_data() { グローバル $WOOCS; グローバル $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')) { ... } }
次のように変更するには:
public function woocommerce_product_options_general_product_data() { グローバル $WOOCS; グローバル $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)) { ... } }