Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Show Button on Woo products loop WordPress

  • SOLVED

I need (add_details) Button to show up with following conditions:
- If product is Variable type
- Before (Add_to_cart) button or After (Price).



The code I have so far below:

$args = array(
'post_type' =>'product',
'paged' => $paged,
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'product_cat' => $categ//entree
);
?>
<h2 class="h-custom-headline man h2"><span><?php echo ucwords($categ); ?></span></h2>
<hr class="x-hr">
<ul class="menu-items">
<?php
add_action('woocommerce_shop_loop_item_title','add_details');
if (!function_exists('add_details')) {
function add_details() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<a href="'.$link.'" class="button selectButton">Select</a>');
}
}
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 1;
}
}
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();

wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo $categ . __( 'Not found' );
}
wp_reset_postdata();
?>
</ul>
<?php }?>

Answers (1)

2016-10-12

Shoeb mirza answers:

if( $product->has_child() ) { echo '<button>Your Add Details button</button> }
Also gave you idea about the price..