简体   繁体   English

在 woocommerce 查看订单中计算无销售价格的小计

[英]calculation of subtotal without sale price in woocommerce view-order

i know my question will not be answered, but i will ask.我知道我的问题不会被回答,但我会问。

i want subtotal to be calculated without considering sale price, that is, to consider the regular price, i did a lot of searching on the net, but i didn't get an answer.我想在不考虑销售价格的情况下计算小计,即考虑正常价格,我在网上做了很多搜索,但没有得到答案。

i think i need to change the calculation method, but i don't know where to start.我想我需要改变计算方法,但我不知道从哪里开始。

echo wc_price( $product->get_regular_price() * $item['quantity'] );

it is not used on the order viewing page because if the order is today and the price changes tomorrow, the new price will be displayed, not the price at the time of placing the order.在订单查看页面上不使用它,因为如果今天订单并且明天价格发生变化,将显示新价格,而不是下订单时的价格。

If you want to access price at the time of order was placed, you will have to access Order object for that.如果您想在下订单时访问价格,您必须访问订单 object。

// Get and Loop Over Order Items
foreach ( $order->get_items() as $item_id => $item ) {
      $subtotal = $item->get_subtotal();
}

Use this links for reference,使用此链接作为参考,

  1. https://www.businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/ https://www.businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/
  2. How to get WooCommerce order details WooCommerce订单详情如何获取

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM