Created
September 1, 2020 08:33
-
-
Save webdados/822bd3d6add49488e946ae68958d7ec4 to your computer and use it in GitHub Desktop.
Only show the WooCommerce Barcode on processing (and completed) orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Add this to your (child-)theme functions.php file | |
//Before woocommerce_email_after_order_table 1 and woocommerce_order_details_after_order_table 1, because on the woocommerce_order_barcodes_display_barcode filter we don't have access to the $order object | |
add_action( 'woocommerce_email_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
add_action( 'woocommerce_order_details_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
function custom_prevent_barcode( $order ) { | |
$allowed_statuses = array( | |
'processing', | |
//'completed', //Uncomment this if you also want the barcode if the order is completed | |
); | |
//Status not allowed? Return false to the woocommerce_order_barcodes_display_barcode filter | |
if ( ! $order->has_status( $allowed_statuses ) ) { | |
add_filter( 'woocommerce_order_barcodes_display_barcode', '__return_false' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment