Woocommerce - Admin Order Detail Page

邮差的信 提交于 2020-01-24 21:07:31

问题


I add one product for e.g “ABC” – price : $10 (including VAT 20%)

So product net price = £8 and tax = £2

In frontend on product detail page i show product price including TAX.($10)

When Customer purchase this product then in woocommerce order generate like this


product price = $8
tax = $2
-------------------
Total = $10

But i want price in admin order detail page like

product price : $10(including 20% VAT)

Not want to show VAT separate.

Thanks


回答1:


Try this. Put it in your theme function.php file

     //Add price inc VAT column on admin order page
function action_woocommerce_admin_order_item_values( $null, $item, $absint ) {
    $val = ($item['type'] == 'line_item' || $item['type'] == 'shipping') ? $item['total'] + $item['total_tax'] : ' ';
    $valdecimal = wc_format_decimal( $val, $dp='', $trim_zeros );
    ?>
    <td class="item_fcost" data-sort-value="<?php echo $val; ?>">
        <div class="view" style="font-weight: bold; text-align: right; padding-right: 10px;">
            <?php if ($val>0) echo '$'; echo $valdecimal;?>
        </div>
    </td>
    <?php
};
add_action( 'woocommerce_admin_order_item_values', 'action_woocommerce_admin_order_item_values', 10, 3 );


function action_woocommerce_admin_order_item_headers( $order ) {
    echo '<th class="item_fcost sortable" data-sort="float" style="text-align: right;">Price inc VAT</th>';
};
add_action( 'woocommerce_admin_order_item_headers', 'action_woocommerce_admin_order_item_headers', 10, 3 );


来源:https://stackoverflow.com/questions/46546482/woocommerce-admin-order-detail-page

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