1

プラグインで WooCommerce フックを使用するにはどうすればよいですか? これが私がやろうとしていることです:

add_filter('woocommerce_edit_product_columns', 'pA_manage_posts_columns');
function pA_manage_posts_columns($columns, $post_type = 'product') {
global $woocommerce;
if ( in_array( $post_type, array( 'product') ) ) {
    $columns['offering_price'] = __( 'offering price', 'your_text_domain' ); // this offering price title 
    $columns['offering_qty'] = __( 'Qty', 'your_text_domain' ); // add the quantity title
    }
unset($columns['name']);
return $columns;

プラグインに WooCommerce を含める方法は次のとおりです。

$ds = DIRECTORY_SEPARATOR;
$base_dir = realpath(dirname(__FILE__)  . $ds . '..') . $ds;
$file = "{$base_dir}woocommerce{$ds}woocommerce.php"; 
include_once($file);

まだ出力を取得できません

print_r($woocommerce);
4

1 に答える 1