Opa. Acho que é aqui:
<td class="total" data-title="<?php esc_html_e('Total', 'shopme') ?>">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
</td>
Mas tá vendo que tem um filtro? Acho que não vamos precisar mexer aí, podemos usar o filtro. Então vai no seu functions.php
e adicione o código abaixo:
/**
* Adiciona as taxas ao subtotal no carrinho
*/
function vta_cart_item_subtotal( $wc, $cart_item, $cart_item_key ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$subtotal = wc_get_price_including_tax( $_product, array( 'qty' => $cart_item['quantity'] ) );
$subtotal = wc_price( $subtotal );
if ( ! empty( $cart_item['line_subtotal_tax'] ) ) {
$_tax = new WC_Tax();
$rates = WC_Tax::get_rates( $_product->get_tax_class() );
if ( ! empty( $rates ) ) {
$rates_string = '';
$total = count( $rates );
$rates = array_values( $rates );
foreach ( $rates as $key => $rate ) {
$tax = WC_Tax::calc_exclusive_tax( (float) $cart_item['line_subtotal'], array( $rate ) );
$rates_string .= wc_price( $tax[0] );
$rates_string .= ' ' . $rate['label'];
if ( $key < ( $total - 2 ) ) {
$rates_string .= ', ';
} else if ( $key == ( $total - 2 ) ) {
$rates_string .= ' e ';
}
}
$subtotal .= '<small class="tax_label" style="display: block;"> (inclui ' . $rates_string . ')</span>';
}
}
return $subtotal;
};
// add the filter
add_filter( 'woocommerce_cart_item_subtotal', 'vta_cart_item_subtotal', 10, 3 );
Além disso, pra ficar bem visualizado no carrinho, vamos alterar o preço também para o valor sem taxas:
/**
* Adiciona as taxas ao subtotal no carrinho
*/
function vta_cart_item_price( $wc, $cart_item, $cart_item_key ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
return wc_price( $_product->get_price() );
};
// add the filter
add_filter( 'woocommerce_cart_item_price', 'vta_cart_item_price', 10, 3 );
Link para o código completo:
https://gist.github.com/mariovalney/b42543f83e1f7c6d8fc16996a99b3855
Com isso, deve ficar tudo OK.
Abraços
-
Esta resposta foi modificada 5 anos, 7 meses atrás por
Mário Valney.