How to add text after price in WooCommerce

To put a string after the price of WooCommerce product and cart pages, use the WooCommerce filters woocommerce_cart_item_price and woocommerce_get_price_html

Add the following code to your active theme functions.php file.

Make sure to change <span class=”price-suffix”>TEXT AFTER THE PRICE</span> with your text or HTML code.

function wpxs_custom_html_addon_to_price( $price, $product ) {

// custom suffix html that you want to add after price

 $html_price_suffix = '<span class="price-suffix"> TEXT AFTER THE PRICE</span>';

 if ( !empty( $price ) ) {
     $price = $price . ' ' . $html_price_suffix;
      return $price;
    } else {
      return $price;
    }
}
add_filter( 'woocommerce_get_price_html', 'wpxs_custom_html_addon_to_price', 999, 2 );
add_filter( 'woocommerce_cart_item_price', 'wpxs_custom_html_addon_to_price', 999, 2 );

NEXT: How to Add text before the price in WooCommerce

Was this post helpful?

Leave a Comment