Price value is printing on shop, category and single product page via get_price_html() function. get_price_html() is a method of WC_Product_Variable class. In this method have a filter “woocommerce_get_price_html”. You can customize the current price structure with this filter as per your requirement.
In this tutorial I use this filter woocommerce_get_price_html and add the custom text after the product price value. Here is thee PHP snippet.
1 2 3 4 5 6 7 8 9 10 11 12 |
/** * Adds Custom Text after Product Price * * @copyright 2019 PaulChinmoy.com * @author Paul Chinmoy */ add_filter( 'woocommerce_get_price_html', 'paulc_add_text_after_price' ); function paulc_add_text_after_price( $price ) { $price .= ' <span class="price-after-text">' . __('per Unit', 'woocommerce' ) . '</span>'; return $price; } |
You will add the above PHP snippet in your functions.php file or your custom helper PHP file.
Leave a Reply