WooCommerce Show price suffix on shop/listing page
Today we are going to talk about how to add a price suffix on all WordPress or WooCommerce shop or listing page. With the use of the below-written code, you can add custom price suffix on both the category and product pages of your WooCommerce website. The good part is that it will not affect your existing price suffix.
add_filter( 'woocommerce_get_price_suffix', 'qaisarsatti_price_suffix', 999, 4 );
function qaisarsatti_price_suffix( $html, $product, $price, $qty )
{
global $woocommerce_loop;
// Not on single products
if ( ( is_product() && isset($woocommerce_loop['name']) && ! empty($woocommerce_loop['name']) ) || ! is_product() )
{
$html .= ' ' . __('Some Text');
}
return $html;
}
function qaisarsatti_price_suffix( $html, $product, $price, $qty )
{
global $woocommerce_loop;
// Not on single products
if ( ( is_product() && isset($woocommerce_loop['name']) && ! empty($woocommerce_loop['name']) ) || ! is_product() )
{
$html .= ' ' . __('Some Text');
}
return $html;
}
Another Method to add the suffix.
add_filter( 'woocommerce_get_price_html', 'qaisarsatti_price_suffix', 999, 4 );
function qaisarsatti_price_suffix( $price, $product )
{
global $woocommerce_loop;
// Not on single products
if ( ( is_product() && isset($woocommerce_loop['name']) && ! empty($woocommerce_loop['name']) ) || ! is_product() )
{
$price .= ' ' . __('Suffix');
}
return $price;
}
function qaisarsatti_price_suffix( $price, $product )
{
global $woocommerce_loop;
// Not on single products
if ( ( is_product() && isset($woocommerce_loop['name']) && ! empty($woocommerce_loop['name']) ) || ! is_product() )
{
$price .= ' ' . __('Suffix');
}
return $price;
}