skip to Main Content

I added a PHP code snippet to my store, but I have the following problem:
The code show the currency symbol and the amount like this “You save: $20”, but in my country the currency symbol is over the number like this “You save: 20 PLN”.

Just need to replace the value of this code, but I don’t know how. I tried everything without success.

<p class="you_save_price">You save: <?php echo $currency_symbol .''. number_format($saved_amount, 2, '.', ''); ?></p>               
        <?php       
    } 

I try to change the position, but it doesn’t work… It throws a syntax error.

How to replace the price amount position and the currency symbol?

2

Answers


  1. Chosen as BEST ANSWER

    The issue is resolved, thank you so much


  2. Simply use WooCommerce dedicated wc_price() function instead, like:

        <p class="you_save_price">You save: <?php echo wc_price($saved_amount); ?></p>  
        <?php       
    } 
    

    or even better:

        <p class="you_save_price"><?php printf( __('You save: %s'), wc_price($saved_amount) ); ?></p>   
        <?php       
    } 
    

    Both should work as expected.

    Note: The WooCommerce price formatting function wc_price() uses your shop formatting price and currency settings and handle multicurrency when enabled by an additional plugin.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search