skip to Main Content

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


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

    But better use hooks from this template.

    Login or Signup to reply.
  2. 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 );
    
    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search