I've searched for replacing add to cart button conditionally on woocommerce. I got a code and I've modified it as per my need. Its working perfectly on the shop page.
Here is My code:
add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_default_button', 10, 2 );
function replace_default_button( $button, $product ){
global $product;
$weight = $product->get_weight();
preg_replace('/\D/', '', $weight);
if ( $product->has_weight() && ($weight > '8') ){
$button = '<a href="#" class="button alt">' . __( "Add to Quote", "woocommerce" ) . '</a>';
}
return $button;
}
But I need a similar code for single product pages as well. How should I do that? Any help?