Untitled
Anonymous
plain_text
09/02/2026 3:49 PM
2.4 KB
1
Indexable
function ww_is_quote_product( $product ) {
return $product && function_exists( 'b2bking' )
&& b2bking()->product_has_quote_rule( $product->get_id() );
}
add_action( 'wp_loaded', function() {
global $b2bking_public;
$objects = array( 'B2bking_Public' );
if ( $b2bking_public instanceof B2bking_Public ) {
$objects[] = $b2bking_public;
}
foreach ( $objects as $object ) {
foreach ( array( 'woocommerce_is_purchasable', 'woocommerce_variation_is_purchasable' ) as $hook ) {
remove_filter( $hook, array( $object, 'b2bking_prevent_cart_product_purchasable' ), 10 );
remove_filter( $hook, array( $object, 'b2bking_prevent_quote_product_purchasable' ), 10 );
}
}
remove_action( 'woocommerce_before_cart', array( 'B2bking_Public', 'b2bking_cannot_quote_offer_cart_message_products' ), 100 );
remove_action( 'woocommerce_single_product_summary', array( 'B2bking_Public', 'unavailable_product_display_message_products' ), 20 );
remove_action( 'woocommerce_single_product_summary', array( 'B2bking_Public', 'unavailable_product_display_message_products_quote' ), 20 );
}, 10 );
function ww_quote_button_text( $text, $product ) {
return ww_is_quote_product( $product )
? esc_html__( 'Add to Quote Request', 'b2bking' )
: $text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'ww_quote_button_text', 99, 2 );
add_filter( 'woocommerce_product_add_to_cart_text', 'ww_quote_button_text', 99, 2 );
add_action( 'woocommerce_after_add_to_cart_button', function() {
global $product;
if ( ! $product || ww_is_quote_product( $product ) ) {
return;
}
echo '<button type="button" class="button alt" style="margin-inline-start:10px" onclick="this.form.querySelector(\'.single_add_to_cart_button\').click();">'
. esc_html__( 'Add to Quote Request', 'b2bking' ) . '</button>';
});Editor is loading...
Leave a Comment