i'm trying to make some changes to the woocommerce barcode plugin. I want to remove this action from the plugin class-woocommerce-order-barcodes.php:

class WooCommerce_Order_Barcodes {
public function __construct ( $file = '', $version = '1.0.0' ) {
add_action( 'woocommerce_order_details_after_order_table', array( $this, 'get_display_barcode' ), 1, 1 );

The reason why i want to remove is because i already have the barcode snippet in another place (inside a tidy DIV in my order-detail.php child template) and the one inserted by the plugin automatically is repeated below (see image) Woocommerce order barcode. The custom code inside the template is this one

<div class="barcode">
    <?php echo WC_Order_Barcodes()->display_barcode($order_id);?>

If course if a remove manually the add_action from the plugin class, i get the result that i want, but i don't want to modify the plugin files. Any idea?

Thanks in advance.

EDIT: the article from here did not resolve my problem, i use the code below and it didn't solve the problem =(


1 Answer 1


You need to access the class variable to remove a action which has been added within a class

function remove_default_order_barcode(){
   global $WooCommerce_Order_Barcodes ;
 remove_action( 'woocommerce_order_details_after_order_table', array( $WooCommerce_Order_Barcodes, 'get_display_barcode' ), 1, 1 );


hope it will help you !

  • Thanks for the reply. It didn't work, still have the default barcode below. Do you need the complete code? I can post the php file. It's 900 lines of code.
    – chenci
    Commented Mar 27, 2017 at 5:49
  • This is the file class-woocommerce-order-barcodes.php. pastebin.com/q5GJ0Mdr
    – chenci
    Commented Mar 27, 2017 at 5:51
  • thanks for sharing code @chenci. I think this can help you to understand it better.
    – Harry
    Commented Mar 27, 2017 at 6:04
  • thank you i will see to it. It's weird, the code you gave me, it should work. Is there a wordpress debug where you can see the code executing behind?
    – chenci
    Commented Mar 28, 2017 at 0:51
  • After reading the article still with no clear answer in this problem
    – chenci
    Commented Mar 28, 2017 at 2:34

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