Dear Support,
I use the Royal theme, and I need some help.
The url: http://www.hazimozistudio.hu
I’d like to add “view details” button next to the add to cart button for every product excerpt listed on the archive posts pages (where users browse the content of a category), to enable users to get to the single product page by clicking it.
http://www.hazimozistudio.hu/termekkategoria/hazimozi-projektor-kepmegjelenites/
If I edit archive-products.php adding a <button>, I can achieve some success, but it doesn’t work properly, and I realized that it might not be the solution. Because I saw all the added <button> at once one after another. I should rather use the hook method.
I wrote some code I paste here, I would like you to please help with some questions about it:
1. Does it seem correct?
2. Where do I have to put it (which file) because editing functions.php makes an instant crash of the site.
The code I wrote:
add_action( ‘woocommerce_after_add_to_cart_button’, ‘add_content_after addtocart_button_func’ );
function add_content_after addtocart_button_func() {
echo ‘<button onclick=”location.href='<?php echo get_permalink( $loop->post->ID ) ?>'” type=”button” class=”details btn btn-default btn-lg”>View details</button>’;
}
Thank you in advance,
Attila