New Landing How can we help? Themeforest Theme Support Neighborhood How to add text "Shipped" after price on main shop page

Viewing 8 posts - 1 through 8 (of 8 total)
  • #148050
    cmw
    Member
    Post count: 11

    Hello, I am trying to find a way to add the word “Shipped” after the price listing on the main product page (ballpythonbreeder.com/shop) (all of my prices include shipping).

    I have found the place to do it for the single product file (content-single-product.php) but cannot locate a similar option for the looped list of products on the main file. I have been through the content-product.php page but the price seems to be coming from somewhere else. Can someone help point me to the correct file to modify? Thanks.

    #148185
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    You are in the correct file in Neighborhood/woocommerce/content-product.php

    The product details start in this line

    <div class="product-details">

    -Rui

    #148234
    cmw
    Member
    Post count: 11

    I’m still getting no love from edits to this file. To test things I added text at all points shown in the image (image1.png). The second image (image2.png) shows the effect on the front-end. Nothing inside that product-details div tag seems to touch price.

    Can you take a peek at the attached images and push me in the direction of my mistake, please? Thanks.

    Colin

    Attachments:
    You must be logged in to view attached files.
    #148513
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please paste this code at functions.php of child theme.

    add_filter( 'woocommerce_get_price_html', 'wp_price_html', 100, 2 );
    function wp_price_html( $price, $product ){
        return  $price.'<span>Shipped<span>';
    }

    Thanks
    Mohammad

    #148567
    cmw
    Member
    Post count: 11

    Hi Mohammad,

    That worked. Thank you.

    However, I do not have a functions.php in my child theme (the only files in the child theme I got from Themeforest was a styles.css and a screenshot.png. I placed the entry in the main theme functions.php file and it works. I assume this means I will lose it when the theme updates. FWIW, it does seem odd to me that my child theme directory is so empty.

    #148570
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please just create empty functions.php file at child theme directory and insert given below code with php tag.

    
    <?php
    add_filter( 'woocommerce_get_price_html', 'wp_price_html', 100, 2 );
    function wp_price_html( $price, $product ){
        return  $price.'<span>Shipped<span>';
    }
    ?>

    Thanks
    Mohammad

    #149156
    cmw
    Member
    Post count: 11

    Excellent. Thank you. Works great.

    For any who may benefit from this in the future, note that Mohammed’s solution will add the text following the price on the single item product page, too.

    If you ONLY wanted to add text after the price on the single product page (content-single-product.php) you can go to line 56 (or somewhere in that range) and find this line (word ‘Shipped’ already added):

    <p itemprop="price" class="price"><?php echo $product->get_price_html(); ?> Shipped.</p>

    Thanks again for the support, Mohammad.

    #149157
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Glad it’s sorted. Thanks Mohammad.
    -Rui

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register