Skip to content

Instantly share code, notes, and snippets.

@grantalltodavid
Created March 17, 2022 07:45
Show Gist options
  • Save grantalltodavid/c83ec1870bf742073b387c9ba0284f0d to your computer and use it in GitHub Desktop.
Save grantalltodavid/c83ec1870bf742073b387c9ba0284f0d to your computer and use it in GitHub Desktop.
Sliced Invoices: remove quantity field from frontend views
add_filter( 'sliced_invoice_line_items_output', 'si20220317_sliced_invoice_line_items_output_custom' );
function si20220317_sliced_invoice_line_items_output_custom( $output ) {
if ( preg_match_all('#<t[hd] class="qty">(.*?)</t[hd]>#', $output, $matches) ) {
$patterns = array();
$replacements = array();
foreach ( $matches[1] as $match ) {
$patterns[] = '#<t[hd] class="qty">'.$match.'</t[hd]>#';
$replacements[] = '';
}
$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