Add Text under Single Product Short Description in Woocommerce - ASP TANMOY

Latest

Sunday 18 November 2018

Add Text under Single Product Short Description in Woocommerce

Add below code on woocommerce theme function.php . This code will automatically show written text on all simple and variable product. This code is and tested working fine .

add_action( 'woocommerce_single_product_summary', 'custom_single_product_summary', 2 );
function custom_single_product_summary(){
    global $product;

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
    add_action( 'woocommerce_single_product_summary', 'custom_single_excerpt', 20 );
}

function custom_single_excerpt(){
    global $post, $product;

    $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

    if ( ! $short_description )
        return;

    // The custom text
    $custom_text = '<ul class="fancy-bullet-points red">
    <li>COD Available. Delivery within 9-10 business days</li>
    </ul>';

    ?>
    <div class="woocommerce-product-details__short-description">
        <?php echo $short_description . $custom_text; // WPCS: XSS ok. ?>
    </div>
    <?php
}

No comments:

Post a Comment