I am trying to display shortcode for the Cart total:
add_shortcode( ‘quote-total’, ‘get_quote_total’ );
function get_quote_total(){
$total = WC()->cart->total;
$disbursement = 0; // Initializng
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if ( has_term( array(‘funeral-types-new’), ‘product_cat’, $cart_item[‘product_id’] ) ) {
$disbursement += $cart_item[‘line_total’] + $cart_item[‘line_tax’];
}
}
$subtotal = $total – $disbursement;
return ‘<div>’.wc_price($subtotal).'</div><div> + ‘.wc_price($disbursement).'</div>’;
}
// USAGE: [quote-total]
// or: echo do_shortcode(‘[quote-total]’);