I am trying to add an extra button to my products on my shop page but only to a specific category. I have gotten this far but I cannot seem to call it up right.
if (!function_exists('add_accessory_button')){
function add_accessory_button() {
global $product;
$product_cat = $product->product_cat;
if( has_term( 'dealqualify',$product_cat ) && in_the_loop() ) {
$link = get_post_meta( $product->ID, ‘acc_link’, true );
echo do_shortcode('<br>[button link="' . esc_attr($link) . '"]View Accessory[/button]');
} }
add_action('woocommerce_after_shop_loop_item','add_accessory_button');
}
Any help to pinpoint my mistake would be appreciated.