• Resolved Jackie Chan

    (@jackie-chan)


    Hi,

    I’m trying to include a column in the cart showing the tax per item, so the cart will have 5 columns:Product, Price, Quantity, Tax, Total

    This code almost achieves it but it’s showing the total tax rather than tax per item & it’s missing the currency symbol:

    <td class="product-tax" data-title="<?php esc_attr_e( 'VAT', 'woocommerce' ); ?>">
    <?php
    echo apply_filters( 'woocommerce_subtotal_tax', WC()->cart->get_subtotal_tax( $_product ), $tax_amount, $cart_item_key, $rate, $price ); // PHPCS: XSS ok.
    ?>
    </td>

    Any ideas?

    • This topic was modified 5 years, 5 months ago by Jackie Chan.
    • This topic was modified 5 years, 5 months ago by Jackie Chan.
    • This topic was modified 5 years, 5 months ago by Jackie Chan.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Half an answer is that the cart is made up of cart items, and you can get at these with:
    $cart_items = WC()->cart->get_cart();
    then you can step through the cart items with:
    foreach( $cart_items as $key => $values) {
    where $key is the cart item key and $values is I think an array with lots of data in it. You may be able to derive the item tax from there.

    The current currency symbol may be obtained from:
    $cs = get_woocommerce_currency_symbol(); // default currency symbol

    Thread Starter Jackie Chan

    (@jackie-chan)

    Thanks for your reply @lorro i’m new to PHP are you able to elaborate on the above?

    Sorry that’s a bit more development work than I would do for a forum answer. Someone else might.

    If not, you could post a job:
    https://jobs.wordpress.net/
    You are not obliged to accept any bid.

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    Hi @jackie-chan,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show tax total for each item within the cart’ is closed to new replies.