How would i use the wooCommerce hooks in my wp plugin? Here is what i am trying to do:

    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
return $columns;


I have included the woocommerce class:

$base_dir = realpath(dirname(__FILE__)  . $ds . '..') . $ds;
$file = "{$base_dir}woocommerce{$ds}woocommerce.php"; 
  • add_filter('woocommerce_edit_product_columns', 'pA_manage_posts_columns',99); try this – codepixlabs Sep 30 '13 at 14:15
  • didn't work, i kinda think that woocommerce is not included in my plugin file, since i can't access the global $woocommerce either. – Mahaein Sep 30 '13 at 14:20
  • This isnt very difficult task to see if plugin is active .. is it ? please check it. – codepixlabs Sep 30 '13 at 14:21
  • Thank you, I activated the plugin, include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); activate_plugin(ABSPATH . 'wp-content/plugins/woocommerce/woocommerce.php'); still can't get the woocommerce hoook to add or remove the columns – Mahaein Oct 1 '13 at 10:08

I believe, the hook is called differently

add_filter( 'manage_edit-product_columns', ... )

The 'woocommerce_edit_product_columns' is not a hook name, but a function name in WC 2.0

As for the access to global $woocommerce - as long as the WooCommerce plugin is loaded, it's available. If, however, your plugin is loaded before WooCommerce (alphabetically), then you can should do something within a function hooked to 'plugins_loaded'.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.