Remove Cents From FoxyShop Price

If your prices are all full dollars and you don’t want to show any cents ($1 instead of $1.00), then you can use the following code snippets to make this happen.

Place this code in your theme’s functions.php file:

add_filter("foxyshop_currency", "my_currency_config");
function my_currency_config($amt) {
    $amt = str_replace(".00", "", $amt);
    return $amt;
}

Place this javascript snippet in your foxyshop-single-product.php file near the end (not necessary if you don’t use variations):

<script type="text/javascript">
function foxyshop_after_variation_modifiers(new_code, new_codeadd, new_price, new_price_original, new_ikey, current_product_id) {
    jQuery(".foxyshop_currentprice").each(function() {
        jQuery(this).text(jQuery(this).text().replace(".00",""));
    });
    jQuery(".foxyshop_oldprice").each(function() {
        jQuery(this).text(jQuery(this).text().replace(".00",""));
    });
}
</script>

This requires FoxyShop 3.4+ and will only remove the cents if they are “.00” – $1.12 will still display the full price.

Posted in: Helpful Code Snippets