check if the product was onsale at the time of ordering and show a message in woocommerce

Viewed 33

i want to make a conditional command that checks if the product that is ordered at the time of the order is onsale, then shows a message

if ( check if at the time of ordering, the product was onsale ) {
    echo 'message';
}

path : C:/xampp/htdocs/i/wp-content/themes/theme-child/woocommerce/myaccount/view-order.php

i can use $product->is_on_sale(); but this onsale checks the product now, not when the order is placed, for example, when the product is not onsale and the order is registered, if the product is onsale later, it should not show a message because the product was not onsale at the time of placing the order.

before : peoduct is not onsale and the order is registered => order id = 5000

ofter : product is onsale

now : it should not display a message because the product was not onsale at the time of placing the order

0 Answers
Related