Add text after price

Davor Mlinarić
13 May 2022

Sometimes is usefull to add additional text under the product price. With this hook you can easily show additional text just under the price. You can use ScriptOrganiser, CodeSnippets or any other similar plugin.

add_filter( 'woocommerce_get_price_html', 'webbox_change_product_price_display' );
function webbox_change_product_price_display( $price ) {
    return $price . '<div>TEXT AFTER PRICE</div>';
}

This hook could be extended to show message only on specific products. In this case you will need to add ID’s of product into array.

add_filter( 'woocommerce_get_price_html', 'webbox_change_product_price_display' );
function webbox_change_product_price_display( $price ) {
    global $post; $product_id = $post->ID;
    $product_array = array( 1,2,3 ); // ids of products
    if ( in_array( $product_id, $product_array )) {
        $price .= '<div>TEXT AFTER PRICE</div>';
    }
    return $price;
}
text-after-price

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy