0

I am trying to add a suffix through a filter hook to a product price in Wooommerce, but for some strange reason the woocommerce_get_price_html filter hook (like explained here) does not change anything to the price.

What can be the obstacle for not adding the suffix? Or do I need to use another hook?

My filter hook:

function pr_price_suffix( $price, $product ) {
   return $price . ' test';
}
add_filter( 'woocommerce_get_price_html', 'pr_price_suffix' );

The code that prints the price in single-product.php:

<?php echo wc_price( wc_get_price_including_tax( $product ) ); ?>
0

I don't think the filter will work in your template, since you're using wc_price( wc_get_price_including_tax( $product ) ) .. a possible workaround:

function pr_price_suffix( $price, $product ) {
 return wc_price( wc_get_price_including_tax( $product ) ). ' test';
}
add_filter( 'woocommerce_get_price_html', 'pr_price_suffix', 10, 2  );

and in your single-product.php template:

 <?php echo $product->get_price_html(); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.