Customizing an additional button on Woocommerce Product Page

  php, product

I have added an extra button on my new product page using the code below:

add_action( 'woocommerce_share', 'mjl_displays2' );

function mjl_displays2() {
global $product;

$category = array( "large-format-print" );

if( is_product() && has_term( $category, 'product_cat', $product->get_id() ) ){
   echo '<div class="body">Cannot find the poster size you need? Use the button below to go to our sister sites custom calculator.</div> 
   <a class="button" style="margin-top: 25px; background-color: #f04d25;color:#ffffff;text-align:center;" href="https://mjldisplays.co.uk/materials/200gsm-poster-paper/" target="_blank">Custom Sizes</a>';
}

}

This code selects products by their categories. However, because the link used in the button is unique to each product, I would like to change this so that the product is selected by its ID.

Source: Ask PHP

LEAVE A COMMENT