What .php file to edit if I wanto add acf field?

This topic has 11 replies, 2 voices, and was last updated 2 years, 3 months ago ago by ziga32

  • Avatar: ziga32
    ziga32
    Participant
    September 12, 2022 at 20:37

    I have a single product page that uses default product layout (not single page builder). Now client wants me to put an extra button on it.

    I have elementor pro but I don’t wanna rebuilt the page with it, so I created a link with acf field, now I just need to know what file to edit so I can insert it’s code in there. Into single product page.

    10 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 13, 2022 at 10:56

    Hello,

    Could you please, provide us with screenshots of your work (where did you create those fields? and where would you like to output them ? )
    Also, it would be better if you could provide us admin+ftp access to help you with your question.

    Regards

    Avatar: ziga32
    ziga32
    Participant
    September 13, 2022 at 15:18

    Sending you the login.

    I created the acf with the link
    https://i.imgur.com/KuwAaFJ.png

    and just want to add it here
    https://i.imgur.com/1dWVhY3.png

    If you need ftp let me know

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 13, 2022 at 15:51

    Hello,

    Please provide FTP access.

    Regards

    Avatar: ziga32
    ziga32
    Participant
    September 13, 2022 at 15:53

    sure

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 13, 2022 at 16:14

    Hello,

    Thanks for the reply.
    I’ve passed this topic to one of our developers, and I will let you know once get an answer. Please be patient and do not change access.
    Thanks in advance.

    Regards

    Avatar: ziga32
    ziga32
    Participant
    September 13, 2022 at 16:23

    thank you

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 15, 2022 at 07:08

    Hello,

    We added next php snippet to your child-theme/functions.php ( https://prnt.sc/Wx7UJoZ5NxVx )

    add_action('init', function() {
    add_action( 'woocommerce_single_product_summary', function() {
    global $product;
    if ( function_exists('get_field')) {
    $value = get_field( 'povezava_na_izdelek', $product->get_id() );
    if ( $value ) { ?>
    <a href="<?php echo esc_url($value); ?>" target="_blank"><?php esc_html_e('Povezava na izdelek', 'xstore-chid'); ?></a>
    <?php }
    }
    }, 55);
    }, 70);

    Single product page -> https://prnt.sc/0iqrIoSnxdkk

    We made link to open in new window but if you need to open it in current window you may change target=”_blank” to target=”_self”.
    All attributes of a tag -> https://www.w3schools.com/tags/tag_a.asp

    If you need to show the own product’s link on each product then there could be better to use next snippet without extra backend working process by adding own link on each product

    add_action('init', function() {
    add_action( 'woocommerce_single_product_summary', function() {
    global $product;
    ?>
    <a href="<?php the_permalink(); ?>" target="_blank"><?php esc_html_e('Povezava na izdelek', 'xstore-chid'); ?></a>
    <?php
    }, 55);
    }, 70);

    // It will add a link of the current product for all products

    Regards

    Avatar: ziga32
    ziga32
    Participant
    September 15, 2022 at 10:47

    My question was what file do I need to edit, I wanted to do this myself without bothering you.

    But it is exactly what I wanted, so thank you very much! !

    ziga

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 15, 2022 at 10:58

    Hello,

    You’re welcome!
    We’d appreciate if you could take a moment to give us 5-stars on ThemeForest! https://themeforest.net/downloads

    Regards

    Avatar: ziga32
    ziga32
    Participant
    September 15, 2022 at 11:03

    already did, the system won’t let me rate the item multiple times.

  • Viewing 11 results - 1 through 11 (of 11 total)

The issue related to '‘what .php file to edit if I wanto add acf field?’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.