In this post I am going to show you how to display WooCommerce discount to customer for product on sale. Sometime when a product is on sale, you want to show total discount to customer on Cart & Checkout pages.
Product Price or Regular Price or Retail Price all are the actual price of the product. The Sale price is a temporary price when a specific product is on sale. The below image “You Saved” section displays the total discount amount.
WooCommerce get_cart() function holds all the data of products added to cart. Call get_cart() function and loop through it to get individual product details.
The get_sale_price() function fetches product sale price and get_regular_price() fetches product actual price.
Add the below code to child theme functions.php file, it displays discount on cart and checkout pages for product on sale.
Flatsome Theme Customization
Custom WooCommerce Plugin Development
WooCommerce Hooks Actions & Filters
Discount Rules for WooCommerce