New Landing How can we help? Themeforest Theme Support Uplift Text under the price

Viewing 11 posts - 1 through 11 (of 11 total)
  • Posted in: Uplift
  • #326829
    micheal_w
    Member
    Post count: 498

    Hi Guys,

    I would like to add a formatted text (with modal) on each product page right under the price.
    Can you please advise how can I achieve that without adding the code individually on each product page?

    Thanks!

    #326830
    micheal_w
    Member
    Post count: 498
    This reply has been marked as private.
    #327119
    David Martin – Support
    Moderator
    Post count: 20834

    You would write a function to hook into the do_action within the WooCommerce single product template file.

    If you look at the file, you can see: do_action( 'woocommerce_single_product_summary' );

    Knowing this, you can then use your child theme to add the code snippet.

    Ex:

    // Add code below product price
    function sf_child_theme_single_product_below_price_code() { ?>
        <!-- Your code here -->
    <?php }
    add_action( 'woocommerce_single_product_summary', 'sf_child_theme_single_product_below_price_code' );

    I’d recommend you add your above code to a new SPB Section and then reference the SPB Section ID shortcode in the above function example. I do not recommend you paste in your code chunk above straight into that function.

    #327157
    micheal_w
    Member
    Post count: 498
    This reply has been marked as private.
    #327160
    micheal_w
    Member
    Post count: 498
    This reply has been marked as private.
    #327167
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    The ID is in the SPB Section URL, from your screenshot that looks like 22094.

    The shortcode would be this:

    [spb_section spb_section_id="14975" width="1/1" el_position="first last"]

    So together you could use:

    // Add code below product price
    function sf_child_theme_single_product_below_price_code() { ?>
        [spb_section spb_section_id="14975" width="1/1" el_position="first last"]
    <?php }
    add_action( 'woocommerce_single_product_summary', 'sf_child_theme_single_product_below_price_code' );
    #327172
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Try this line instead.
    do_shortcode('[spb_section spb_section_id="22094" width="1/1" el_position="first last"]');

    -Rui

    #327177
    micheal_w
    Member
    Post count: 498
    This reply has been marked as private.
    #327180
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    You need will need some PHP experience to do this modification.

    // Add code below product price
    function sf_child_theme_single_product_below_price_code() {
        echo do_shortcode('[spb_section spb_section_id="22094" width="1/1" el_position="first last"]');
    }
    add_action( 'woocommerce_single_product_summary', 'sf_child_theme_single_product_below_price_code' );
    #327183
    micheal_w
    Member
    Post count: 498

    Woohoo, works perfectly, thank you!

    #327190
    David Martin – Support
    Moderator
    Post count: 20834

    Glad to help!

    If you have found the theme/support useful, we appreciate it if you can leave feedback on our item if you have the time as it really helps us out.

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

You must be logged in to reply to this topic.