0

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 Answers3

1

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"

0

You can add in your theme folder woocommerce\cart\cart.php and update default template https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart.php

But better use hooks from this template.

WP Punk
  • 1,344
  • 9
  • 25
0

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:

echo apply_filters( 'woocommerce_cart_item_price', apply_filters( 'woocommerce_cart_product_price', wc_price( $_product->get_price_excluding_tax( $_product ) ), $_product ), $cart_item, $cart_item_key );
Snuwerd
  • 459
  • 3
  • 6
  • Is the price excluding tax known for the product? Or did you perhaps only fill in the 'including tax' price? I am sorry, I don't know if such a thing exists. I know that under Woocommerce > Settings > Tax tab it asks if you want to enter prices including or excluding taxes, you might have to set this to set price exluding taxes. – Snuwerd Nov 19 '19 at 11:01
  • i introduce the price in products without tax. but in configuration o woocomerce put show with tax in cart and now i want two line with and without tax – Angel Mahe Nov 19 '19 at 11:07