I want add other line to cart form to show the price with an without tax.
Product | price with tax | price no tax | quantity | total
Im not sure if there is some code to add like hook or some code to fundctions.php or it can be done through woocomerce settings, have not found any useful information online, any help is appreciated.
i try duplicante this line:
<td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
?>
</td>
and change for:
<td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_price_excluding_tax( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
?>
</td>
but it not work
3
Answers
You can add in your theme folder
woocommercecartcart.php
and update default template https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart.phpBut better use hooks from this template.
I don’t fully understand why get_price_excluding_tax() function is available in Cart class in code of the Woocommerce plugin, but I realized its a Product class function, so I am calling it on $_product now and it seems to work. So try this:
I think you are looking for:
To display price without tax + tax amount + price including tax (on separated lines):
First read “How to override Woocommerce templates via your theme“