How to paste 'buy' button under the product in Woocommerce

Asked

Viewed 5,276 times

-1

I’m making an Ecommerce with Woocommerce for wordpress.

I would like to know how and in which file put a "buy" button, where when clicking it it does not add to cart, but rather direct the product page. ( the theme does not provide this option, why it has to be done by hand

  • http://chrislema.com/improving-the-woocommerce-add-to-cart-button/

2 answers

2

The Woocommerce files relating to the presentation of contents (templates) are in the folder

/wp-content/plugins/Woocommerce/templates/

In this folder you can see the base templates (among others):

Archive-product.php - presents a list of products

single-product.php - product details

This single-product file fetches the data from the folder /single-product... is in that folder that you can make changes to the product page... yet in this folder you can see the sub-folder /add-to-Cart where have the models for the button.

As for changing the behavior of the button I don’t know how it will be, but it is possible!

Another important thing, do not modify files here, copy them to your theme folder so that it looks like this: .../o_seu_tema/Woocommerce/templates/... and then modify those files in your theme! If you modify them in the plugin folder you will run out of those modifications when you update Woocommerce!

0

To change the button link we will have to edit the functions.php file located in wordpress/wp-content/themes/"your theme in use"/

function custom_woocommerce_loop_add_to_cart_link( $html, $product ) {
return '<a href="LINK PARA PAGINA DE DESTINO" class="button">' . __( 'Comprar' ) . '</a>';
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_woocommerce_loop_add_to_cart_link', 10, 2 );

Open the above mentioned file in the text editor of your choice and copy this code. Change the "LINK TO DESTINATION PAGE" by the link of the page you want to redirect the button and save.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.