2

On my woocommerce website, I want to add a symbol '.-' after price wherever the price appears. I am using the code below in my functions.php file.

add_filter( 'woocommerce_get_price_html', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );

function kd_custom_price_message( $price ) {
    $afterPriceSymbol = '.-';
    return $price . $afterPriceSymbol;
}

As you can see I am using two filters -

  1. woocommerce_get_price_html: for product display on shop and product page.

  2. woocommerce_cart_item_price: ir changes the way product prices are shown in the cart table (not at checkout since only quantity / total price are shown here, not the unit price).

That adds symbols for price on shop page, product single page and cart page but does not add for price totals on cart page and checkout page.

So, my question is how I can add the symbol for price totals on cart page and checkout page.

Website reference

cart page

check out page

closed as off-topic by Mark Kaplun, cjbj, bueltge, cybmeta, kaiser Sep 7 '16 at 20:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

6

I found the hooks you were looking for by reviewing the WooCommerce template source code (review-order.php). Here's the code:

add_filter( 'woocommerce_get_price_html', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' ); // added
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' ); // added
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' ); // added
function kd_custom_price_message( $price ) {
    $afterPriceSymbol = '.-';
    return $price . $afterPriceSymbol;
}

It's worth noting that WooCommerce > Settings > Currency Options > Number of Decimals is set to 0 in this example.

Cart enter image description here

Checkout enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.