wordpress 在WooCommerce订单快速查看中显示订单总额[关闭]

ljsrvy3e  于 5个月前  发布在  WordPress
关注(0)|答案(1)|浏览(116)

**已关闭。**此问题为not about programming or software development。目前不接受回答。

此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site的主题相关,可以发表评论,说明在何处可以回答此问题。
24天前关闭。
Improve this question
我想在订单预览弹出窗口中显示订单总额,如下图所示。


的数据

wztqucjr

wztqucjr1#

基于在WooCommerce中显示使用过的优惠券为了快速查看答案,您可以使用以下方法将订单总额添加到WooCommerce订单快速查看:

// Add custom order data to make it accessible in Order preview template
add_filter( 'woocommerce_admin_order_preview_get_order_details', 'admin_order_preview_add_order_total', 10, 2 );
function admin_order_preview_add_order_total( $data, $order ) {
    $data['order_total'] = strip_tags( wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ) );
    return $data;
}

// Display The data in Order preview
add_action( 'woocommerce_admin_order_preview_end', 'display_order_total_in_admin_order_preview' );
function display_order_total_in_admin_order_preview(){
    // Call the stored value and display it
    echo '<div><table cellspacing="0" class="wc-order-preview-table"><thead><tr>
        <th class="wc-order-preview-table__column--total">' . __('Total') . '</th>
        <td class="wc-order-preview-table__column--total-amount">{{{data.order_total}}}</td>
    </tr></thead></table></div>';
}

字符串
代码放在你的子主题的functions.php文件中(或插件中)。测试和工作。


的数据

相关问题