wc_format_sale_price

Format a sale price for display.

Description

(string) wc_format_sale_price( (string) $regular_price, (string) $sale_price ); 

Returns (string)

Parameters (2)

0. $regular_price (string)
The regular price.
1. $sale_price (string)
The sale price.

Usage

  1. if ( !function_exists( 'wc_format_sale_price' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The regular price. 
  5. $regular_price = ''; 
  6.  
  7. // The sale price. 
  8. $sale_price = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_format_sale_price($regular_price, $sale_price); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_format_sale_price( $regular_price, $sale_price ) { 
  2. $price = '<del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>'; 
  3. return apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price );