Your cart is currently empty!
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
- Log into a staging or locally hosted clone of your site.
- Install and activate Code Snippets plugin.
- WP Admin > Snippets > Add New
- Copy and paste the code from the section above.
- Check to ensure formatting came over properly.
- Customize the code as desired.
- Add a meaningful title.
- Select whether to run on front-end or back-end (or both).
- Click “Save and Activate”.
- Test your site to ensure it works.
- Disable if any problems, or recover.
- 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
Note: I may receive compensation for referrals.