Show subtotal excl. tax, add subtotal tax as separate row on Woocommerce checkout

ε祈祈猫儿з 提交于 2021-02-09 06:47:46

问题


Currently I have all my products set to include tax. Because of rules in my country I would like to have my subtotal without tax, then a line with the amount of tax being paid and then the total with all the taxes (which is already default)

In my review-order.php the line <td><?php wc_cart_totals_subtotal_html(); ?></td> gets called. I would like to subtract the tax percentage (21%) from that so ( / 121 * 100). And then a new line which shows the full tax amount so (total - subtotal).


回答1:


Updated: First, for info, woocommerce templates are made to be overridden via your active theme.

Once you have copied the template checkout/review-order.php to the "woocommerce" subfolder located in your theme (as explained on the linked documentation above), open/edit this template and replace the following code block (line 58 to 61):

<tr class="cart-subtotal">
    <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
    <td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>

By this code bloc:

<tr class="cart-subtotal">
    <th><?php printf( __( 'Subtotal %s', 'woocommerce' ), '<small>(excl. tax)<small>' );?></th>
    <td><?php echo wc_price( WC()->cart->get_subtotal() ); ?></td>
</tr>

<tr class="cart-subtotal-tax">
    <th><?php _e( 'Subtotal tax', 'woocommerce' ); ?></th>
    <td><?php echo wc_price( WC()->cart->get_subtotal_tax() ); ?></td>
</tr>

It will give you the subtotal without taxes and on an additional line the subtotal tax amount…




回答2:


Go to your Tax options in WC settings and ensure the Prices entered with tax option is set to 'Yes, I will enter prices inclusive of tax.'

Change Display prices during cart and checkout option from 'Including tax' to 'Excluding tax'.

That should help you achieve what you want without using any code.



来源:https://stackoverflow.com/questions/53872130/show-subtotal-excl-tax-add-subtotal-tax-as-separate-row-on-woocommerce-checkou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!