2

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 =(

closed as off-topic by Mark Kaplun, cjbj, bosco, Dave Romsey, Fayaz Apr 7 '17 at 18:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

4

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 !

  • 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 Mar 27 '17 at 5:49
  • This is the file class-woocommerce-order-barcodes.php. pastebin.com/q5GJ0Mdr – chenci Mar 27 '17 at 5:51
  • thanks for sharing code @chenci. I think this can help you to understand it better. – Harry Mar 27 '17 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 Mar 28 '17 at 0:51
  • After reading the article still with no clear answer in this problem – chenci Mar 28 '17 at 2:34

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