Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Format WooCommerce Sale Prices for Accessibility.
<?php
/**
* Format WooCommerce Sale Prices for Accessibility.
*/
function modify_woocommerce_format_sale_price( $price, $regular_price, $sale_price ) {
$price = '<span class="sr-only">Original price</span> <s>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</s> <span class="sr-only">sale price</span> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>';
return $price;
}
add_filter( 'woocommerce_format_sale_price', 'modify_woocommerce_format_sale_price', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment