Quote Request logic

Reqest-a-quote logic for $0.00 priced products. If you need a more advanced version of this functionality, check out the official extension Request a Quote for WooCommerce.

// Force Everything Purchasable
add_filter( 'woocommerce_is_purchasable', '__return_true' );

// Force Variations Enablement
add_filter( 'woocommerce_hide_invisible_variations', '__return_false' );

add_filter( 'woocommerce_variation_is_visible', function( $is_visible ) {

	return true;

} );

// Simple Products - Force No Price Products Zero - Prevents PHP 8.0 Crash
add_filter( 'woocommerce_product_get_price', function( $price ) {

	return $price ? $price : 0.00;

} );

// Variation Products - Force No Price Products Zero - Prevents PHP 8.0 Crash
add_filter( 'woocommerce_product_variation_get_price', function( $price ) {

	return $price ? $price : 0.00;

} );

// Display: Empty Product Price
add_filter(
	'woocommerce_empty_price_html',
	function() { return 'RFQ'; }
);
add_filter(
	'woocommerce_variable_empty_price_html',
	function() { return 'RFQ'; }
);
add_filter(
	'woocommerce_variation_empty_price_html',
	function() { return 'RFQ'; }
);

// Display: Single Product Variation Price Range
add_filter( 'woocommerce_variable_price_html', function( $price_html, $product ) {
 
    $price_numeric = floatval( $product->get_price() );
 
    return $price_numeric > 0 ? $price_html : 'RFQ';
 
}, 10, 2 );

// Display: Single Product Price
add_filter( 'woocommerce_get_price_html', function( $price_html, $product ) {
 
    $price_numeric = floatval( $product->get_price() );
 
    return $price_numeric > 0 ? $price_html : 'RFQ';
 
}, 10, 2 );

// Display: Order Item Table Price
add_filter( 'woocommerce_cart_item_price', function( $price, $cart_item ) {

	$price_numeric = floatval( $cart_item['line_subtotal'] );

	return $price_numeric > 0 ? $price : 'RFQ';

}, 10, 2 );

// Display: Order Item Table Subtotal
add_filter( 'woocommerce_cart_item_subtotal', function( $price, $cart_item ) {

	$price_numeric = floatval( $cart_item['line_subtotal'] );

	return $price_numeric > 0 ? $price : 'RFQ';

}, 10, 2 );

// Display: Cart Subtotal
add_filter( 'woocommerce_cart_subtotal', function( $subtotal ) {

	return $subtotal == wc_price( '0.00' )
		? 'RFQ' : $subtotal;

} );

// Emails: Order Item Table Subtotal
add_filter( 'woocommerce_order_formatted_line_subtotal',
	function( $subtotal ) {

	return $subtotal == wc_price( '0.00' )
		? 'RFQ' : $subtotal;

} );

// Emails: Cart Subtotal
add_filter( 'woocommerce_order_subtotal_to_display', function( $subtotal ) {

	return $subtotal == wc_price( '0.00' )
		? 'RFQ' : $subtotal;

} );

Instructions for Quote Request logic

  1. Log into a staging or locally hosted clone of your site.
  2. Install and activate Code Snippets plugin.
  3. WP Admin > Snippets > Add New
  4. Copy and paste the code from the section above.
  5. Check to ensure formatting came over properly.
  6. Customize the code as desired.
  7. Add a meaningful title.
  8. Select whether to run on front-end or back-end (or both).
  9. Click “Save and Activate”.
  10. Test your site to ensure it works.
  11. Disable if any problems, or recover.
  12. Repeat for live environment.

Need help modifying Quote Request logic?

Contact me. I can help with fitting projects or refer to my partner.

License

All code snippets are licensed GPLv2 (or later) matching WordPress licensing.

Except when otherwise stated in writing the copyright holders and/or other parties provide the program as-is without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.

Disclaimer of warranty