I stripped out a lot of the code that wouldn’t be needed in a shortcode:
function sx372821_request_quote_button( $atts = array() ) {
global $product;
$atts = shortcode_atts( array(
'button_text' => get_option( 'wc_quote_button_text' ),
), $atts, 'request_quote_button' );
$product_id = $product->get_id();
$wc_quote_button_text = esc_html( $atts['button_text'] );
if ( empty( $wc_quote_button_text ) ) {
$wc_quote_button_text = esc_html__( 'Request Quote', 'woocommerce' );
}
return "<button class=\"open-wc-quote-form single_add_to_cart_button button alt\" data-product=\"{$product_id}\">{$wc_quote_button_text}</button>";
}
add_shortcode( 'request_quote_button', 'sx372821_request_quote_button' );
Now you can do:
[request_quote_button]
or specify the button text if you want to override the default:
[request_quote_button button_text="Get a Quote"]