2 Replies - 352 Views - Last Post: 08 October 2019 - 04:59 AM

#1 davidovic   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-September 19

WooCommerce - Buy product button and Align buttons

Posted 23 September 2019 - 10:04 AM

Hi,

I'm a newbie and I'm facing some issues in WooCommerce and I need your help.

The issues are as following:

1/ When we select an external product in WooCommerce a "Buy product" button is automatically displayed on a single product page. But this button overwrites

the "View" button displayed on the homepage or on the category page.

I want to have these settings for the "Buy product" button:
- to display only on a single product page and NOT to overwrite other buttons
- to open a "New browser tab" when we click on it

Then we will have this configuration:
- "View" button on homepage and category page points to a single product page
- "Buy product" button on a single product page opens a "New browser tab" and points to an external link

2/ I want also align "buttons, rating stars & prices" under the pics. Effectively, when we have more than 4 or 5 words in the product's name the "buttons,

rating stars & prices" move down and create a gap. I wish that they move as a block and ALIGN them in one row.

Many Thanks for the Help.

Is This A Good Question/Topic? 0
  • +

Replies To: WooCommerce - Buy product button and Align buttons

#2 TechGeek6969   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-November 18

Re: WooCommerce - Buy product button and Align buttons

Posted 24 September 2019 - 02:42 PM

If possible please share the code you are working with, by viewing the code it will make things easier as we try to assist you.
Was This Post Helpful? 0
  • +
  • -

#3 nesir28   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 60
  • Joined: 11-August 17

Re: WooCommerce - Buy product button and Align buttons

Posted 08 October 2019 - 04:59 AM

This is a common request. The loops withing the template and the single product template and the category archive template differs. To do it properly you would have to go find those templates and re code the php loop withing them. However you can fix this with functions and hooks. This view will link to a single product and there the add to cart will be displayed. Add it to the bottom of your funtions.php file. It should work unless your theme has modified the core woo functions. just to be safe do this on a child theme and make a copy of the functions php before editing anything. If it crashes your site and you cant get back to the editor do so via ftp
// First, remove Add to Cart Button

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
  
// Second, add View Product Button
  
add_action( 'woocommerce_after_shop_loop_item', 'custom_view_product_button', 10 );
  
function custom_view_product_button() {
global $product;
$link = $product->get_permalink();
echo '<a target=_blank href="' . $link . '" class="button addtocartbutton">View Product</a>';
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1