dpepbjp126917 2016-08-10 13:58
浏览 47
已采纳

通过订单ID获取订单总计,而无需在WooCommerce中设置格式

How can I get all order totals without price formatting in WooCommerce?

I have tried this:

$order->get_order_item_totals()

But I get formatted prices like this:

cart_subtotal = array( 
   'label' => Subtotal
   'value' => <span class="amount">$30.75</span><small class="tax_label">(ex. tax)</small>
)
total = array( 
   'label' => Total
   'value' => <span class="amount">$30.75</span>
)

Instead, I would like to have something like this:

cart_subtotal = array( 
   'label' => Subtotal
   'value' => 30.75
)
total = array( 
   'label' => Total
   'value' => 30.75
)
  • 写回答

2条回答 默认 最新

  • dongyou2635 2016-08-11 14:38
    关注

    Try This

    if ( $subtotal = (float)$order->get_subtotal()) {
    $total_rows[] = array(
        'title' => 'Subtotal:',
        'value' => $subtotal
    );
    }
    if ($cart_discount = (float)get_post_meta($order_id, '_cart_discount', true)) {
    $total_rows[] = array(
        'title' => 'Discount:',
        'value' => $order->cart_discount
    );
    }
    if ($order_shipping = (float)get_post_meta($order_id, '_order_shipping', true)) {
    $total_rows[] = array(
        'title' => 'Shipping:',
        'value' => $order_shipping
    );
    }
    if ($order_tax = (float)get_post_meta($order_id, '_order_tax', true)) {
    $total_rows[] = array(
        'title' => 'tax:',
        'value' => $order_tax
    );
    }
    if ($gettotals = (float)$order->get_total()){
    $total_rows[] = array(
        'title' => 'Total:',
        'value' => $gettotals
    );
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?