Last active
June 8, 2022 16:51
-
-
Save kimcoleman/64daef80d23f89468531e31ffa3375ef to your computer and use it in GitHub Desktop.
Format WooCommerce Sale Prices for Accessibility.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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