- get_price_html() /woocommerce/includes/abstracts/abstract-wc-product.php, , html :
- woocommerce_sale_price_html
- woocommerce_price_html
- woocommerce_empty_price_html
- woocommerce_free_sale_price_html
- woocommerce_free_price_html
- woocommerce_get_price_html
, , html, woocommerce_get_price_html. HTML HTML.
add_filter( 'woocommerce_get_price_html', function( $price, $product )
{
global $woocommerce_loop;
if ( is_product() && !isset( $woocommerce_loop ) && $product->get_price() && $product->is_on_sale() ) {
$prices = array_map( function( $item ) {
return array( $item, (float) preg_replace( "/[^0-9.]/", "", html_entity_decode( $item, ENT_QUOTES, 'UTF-8' ) ) );
}, explode( ' ', strip_tags( $price ) ) );
$price = isset( $prices[0][0] ) ? '<span class="orig-price">Original Price: ' . $prices[0][0] . '</span>' : '';
$price .= isset( $prices[1][0] ) ? '<span class="sale-price">Sale Price: ' . $prices[1][0] . '</span>' : '';
if ( $product->get_regular_price() ) {
$price .= '<span class="saved">You saved: ' . sprintf( get_woocommerce_price_format(), get_woocommerce_currency_symbol(), $prices[0][1] - $prices[1][1] ) . '</span>';
}
}
return $price;
}, 10, 2 );
span divs, . price.php, /themes/yourtheme/woocommerce/single-product/.