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.

 

 

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.