I am facing an issue with adding currency codes after the price in WooCommerce. I used the following hook to achieve this:
add_action( 'wp_loaded', 'add_currency_code_to_price' );
function add_currency_code_to_price() {
$currency = get_woocommerce_currency(); // Get current currency code
add_filter( 'wc_price', function( $formatted_price, $price, $args ) use ( $currency ) {
// Append currency code after the price
$formatted_price .= ' <span class="currency-code">' . $currency . '</span>';
return $formatted_price;
}, 999, 3 );
}
This code works properly on product pages and other pages, but it does not display the currency code on product grid pages (e.g., shop or category pages where products are displayed in a list or grid). If I directly modify the currency symbol, it works correctly on all pages, including product grid pages. However, when adding the currency code after the price, it does not show up on grid pages.
Is there any specific hook that could be used to correctly add the currency code on product grid pages?
Thank you for your assistance!