Reputation: 21
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?
Upvotes: 1
Views: 1074
Reputation: 254363
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.
Upvotes: 0