Last active
September 19, 2017 11:24
-
-
Save grantalltodavid/a23bc1632e524cba8d33773712cba074 to your computer and use it in GitHub Desktop.
Sliced Invoices: Show quantity field as whole numbers only, no decimals
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
add_filter( 'sliced_invoice_line_items_output', 'sliced_invoice_line_items_output_custom' ); | |
function sliced_invoice_line_items_output_custom( $output ) { | |
if ( preg_match_all('#<td class="qty">(.*?)</td>#', $output, $matches) ) { | |
$patterns = array(); | |
$replacements = array(); | |
foreach ( $matches[1] as $match ) { | |
$patterns[] = '#<td class="qty">'.$match.'</td>#'; | |
$replacements[] = '<td class="qty">'.intval($match).'</td>'; | |
} | |
$output = preg_replace($patterns, $replacements, $output); | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment