Created
July 26, 2023 09:08
-
-
Save picocodes/837fb79886105b3ac70a4a7e106d614e to your computer and use it in GitHub Desktop.
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 discount column. | |
add_filter( 'manage_wpi_invoice_posts_columns', function( $columns ) { | |
$columns['discount_code'] = __( 'Discount Code', 'invoicing' ); | |
return $columns; | |
}, 999 ); | |
// Display discount column. | |
add_action( 'manage_wpi_invoice_posts_custom_column', function( $column_name, $post_id ) { | |
if ( 'discount_code' === $column_name ) { | |
$invoice = new WPInv_Invoice( $post_id ); | |
$discount = $invoice->get_discount_code(); | |
if ( ! empty( $discount ) ) { | |
echo wp_kses_post( $discount ); | |
} else { | |
echo '—'; | |
} | |
} | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment