Change currency symbol based on product category in Woocommerce

强颜欢笑 提交于 2019-12-06 04:19:05

Related: Custom cart item currency symbol based on product category in Woocommerce 3.3+

You need to put return $currency_symbol; outside the if statement this way:

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
    global $post, $product;

    if ( has_term( 'clearance', 'product_cat' ) ) {
        switch( $currency ) {
             case 'USD': $currency_symbol = '$$$'; 
             break;
        }
    }
    return $currency_symbol; // <== HERE
}

Code goes in function.php file of your active child theme (or active theme).

Now it should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!