Substitute add to cart button when product price is empty
-
I would like to build a function which creates a contact button when the price field is empty on a product page. My idea is to create the button instead of the “add to cart” button and be located on the same position.
Here is my code:
function add_contact_link( $price, $product ) { if ( '' === $product->get_price() || 0 == $product->get_price() ) : return '<a href="" class="">Contáctanos</a>'; endif; } add_filter( 'woocommerce_after_add_to_cart_button', 'add_contact_link', 100, 2 );
The issue is that the button doesn’t show up on the frontend.
Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Substitute add to cart button when product price is empty’ is closed to new replies.