I am trying to add some text after the short description on woocommerce. I have come up with the following add action but when I use it, it replaces the existing short description text.

Is there a way to add this after the existing short description without replacing?

function show_shipping_price() {
    echo 'Order within <b>3 hours 27 minutes</b> to get it delivered for <b>only £1</b>';
add_filter( 'woocommerce_short_description', 'show_shipping_price' );

closed as off-topic by Robert hue, Brad Dalton, Sisir, Nicolai, Mayeenul Islam Jul 16 '15 at 15:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


The Correct syntax for writing a add_filter

// Define the woocommerce_short_description callback  
function filter_woocommerce_short_description( $post_excerpt )   {  
    // make filter magic happen here...
    return $post_excerpt;
// add the filter
add_filter( 'woocommerce_short_description',filter_woocommerce_short_description',10, 1 );

Your code didn't work well because the reason is that filter are used to modify the output. Here is the function parameter you get the $post_excerpt parameter which will be displayed if not filters modify it. If you want to achieve your purpose you can return you desired string with the $post_excerpt . You just need to modify the above code i mentioned with function like

function filter_woocommerce_short_description( $post_excerpt )   {
    $your_msg='Order within <b>3 hours 27 minutes</b> to get it delivered for <b>only £1</b>';
    return $post_excerpt.'<br>'.$your_msg; 

Try this and lemme know if it works will for you.

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