Skip to content

Instantly share code, notes, and snippets.

@grantalltodavid
Last active September 19, 2017 11:24
Show Gist options
  • Save grantalltodavid/a23bc1632e524cba8d33773712cba074 to your computer and use it in GitHub Desktop.
Save grantalltodavid/a23bc1632e524cba8d33773712cba074 to your computer and use it in GitHub Desktop.
Sliced Invoices: Show quantity field as whole numbers only, no decimals
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