-1

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.

1 Answers1

0

If you want to access price at the time of order was placed, you will have to access Order object for that.

// 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/
  2. How to get WooCommerce order details
Megamind
  • 33
  • 5
  • i apologize for answering late, if it is an onsale product, if i use get_subtotal, it will calculate the sale price in the subtotal, i want you to calculate the regular price. emaple : regular : $100 | sale : $90 => subtotal : $100 * quantity –  Sep 16 '22 at 04:47
  • in addition, i want to put the price of the product on the order view page when placing the order, if i use this, it gives an error : `foreach ( $order->get_items() as $item_id => $item ) {echo $item->get_regular_price();}` –  Sep 16 '22 at 04:59
  • `foreach ( $order->get_items() as $item_id => $item ) {$product = $item->get_product();echo $product->get_regular_price();}` : this also shows the current price of the product, not the price at the time of placing the order –  Sep 16 '22 at 05:13