我剥离了许多短代码中不需要的代码:
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\' );
现在您可以执行以下操作:
[request_quote_button]
如果要替代默认设置,请指定按钮文本:
[request_quote_button button_text="Get a Quote"]