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);?>
</div>

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 );

}
 add_action('init','remove_default_order_barcode');

hope it will help you !

Leave a Reply

Your email address will not be published. Required fields are marked *