// remove add to cart button for every product
add_action( 'init', 'prfx_remove_add_to_cart_button');
function prfx_remove_add_to_cart_button() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); // catalog page
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30); // single product page
}
So in the frontend/browser this link will look like/point to:
https://example.com/product-inquiry/?product-title=My Product&product-id=132
(UPDATE)
You should use WooCommerce hooks to insert the new button in place of the old button.
Also if you use variations, its get compicated fast.
For example, you could insert the inquiry button with something like this:
// add inquiry button into every product
// we use the same hooks as before, to insert the new content on the same spot
add_action( 'woocommerce_after_shop_loop_item', 'prfx_add_inquiry_button', 10); // catalog page
add_action( 'woocommerce_single_product_summary', 'prfx_add_inquiry_button', 30); // single product page
function prfx_add_inquiry_button() {
$current_product_id = get_the_ID(); // get ID of the current post
$current_product_title = get_the_title(); // get the title of the current post
$product = wc_get_product( $current_product_id ); // get the product object
// create a button for variable/variant products
if ($product->is_type( 'variable' )) {
$variations = $product->get_available_variations(); // get all available variations of the current product
if ($variations) {
foreach ($variations as $variation) {
if ($variation['variation_is_active'] == 1) {
echo '<div>';
// use this to see all available data
// print_r($variation);
$variation_price_html = $variation['price_html']; // variation price html, for example "€150,00 incl. vat"
$variation_id = $variation['variation_id']; // variation ID, for example "2006"
$variation_title = get_the_title( $variation_id ); // variation title, for example "Beanie with Logo - red, medium"
// we create a button for each single available variation
echo '<a href="'.home_url('/product-inquiry').'/?product-title='.$variation_title.'&product-id='.$variation_id.'" class="button">';
echo $variation_title; // show title
echo '<br>';
echo $variation_price_html; // show price html
echo '</a>';
echo '</div><br>';
}
}
}
// create a button for simple products
} elseif ($product->is_type( 'simple' )) {
echo '<a href="'.home_url('/product-inquiry').'/?product-title='.$current_product_title.'&product-id='.$current_product_id.'" class="button">';
echo $current_product_title;
echo '</a>';
}
}