user6677795
user6677795

Reputation:

How to add suffix text to price in WooCommerce cart and checkout page?

I need to add a text mention after prices (sub-total, total...) displayed in my cart page and checkout page.

I know how to do that on single page and shop page but not on the other pages. The only thing I found is this code, but it does not work.

add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message( $price ) {
  $text = 'lorem';
  return $price . $text;
}

Upvotes: 3

Views: 4453

Answers (3)

Mervin
Mervin

Reputation: 26

add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
function cw_change_product_price_display( $price ) {
    $text = __(' X ');
    return $price . ' ' . $text;
}

For cart page you can try this code.

Upvotes: 0

Arthur M
Arthur M

Reputation: 53

For shipping price :

add_filter( 'woocommerce_cart_shipping_method_full_label', 'kd_custom_price_message' );

Upvotes: 1

user6677795
user6677795

Reputation:

I found the answer but it does not add to shipping price:

add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' );  
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' );  
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' ); 

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

Upvotes: 5

Related Questions