This topic has 11 replies, 2 voices, and was last updated 2 years, 3 months ago ago by ziga32
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.
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
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
Hello,
Please provide FTP access.
Regards
sure
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
thank you
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
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
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
already did, the system won’t let me rate the item multiple times.
Tagged: edit, field, template, woocommerce, wordpress
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