Skip to content

Instantly share code, notes, and snippets.

@PechenkiUA
Created March 22, 2021 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PechenkiUA/c8c0d236a81447daf82450aa01d2c390 to your computer and use it in GitHub Desktop.
Save PechenkiUA/c8c0d236a81447daf82450aa01d2c390 to your computer and use it in GitHub Desktop.
Telsender free item
function telsender_fee_total($list, $order_id){
// (optional if not defined) An instance of the WC_Order object
$the_order = wc_get_order( $order_id );
$fee_total = 0;
// Iterating through order fee items ONLY
foreach( $the_order->get_items('fee') as $item_id => $item_fee ){
// The fee name
$fee_name = $item_fee->get_name();
// The fee total amount
$fee_total += $item_fee->get_total();
// The fee total tax amount
$fee_total_tax = $item_fee->get_total_tax();
}
$list['{fee_total}'] = $fee_total ;
return $list;
}
add_filter( 'tscf_filter_codetemplate','telsender_fee_total', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment