Get Product Discounted Price After Checkout or Order page.php
Retrieve the discounted price of a product after checkout or on the order page.
<?php
if (function_exists('wc_get_order') && $order = wc_get_order($order_id)) { // pass order id here
foreach($order->get_items() as $item) { // loop each order item in order
$product = $item->get_product(); // to get product from order item
$quantity = $item->get_quantity(); // to get quantity from order item
if ($product) {
$regular_price = $product->get_regular_price();
$sale_price = $product->get_price();
$discount = $item->get_meta('_advanced_woo_discount_item_total_discount'); // to get discount data from order item meta
if ($discount && isset($discount['discounted_price'])) {
$regular_price = $discount['initial_price'];
$sale_price = $discount['discounted_price'];
}
if ($regular_price > $sale_price) {
$you_saved = $regular_price - $sale_price;
}
// here you will get the product regular, sale or discounted and saved prices
}
}
}