Perry Comfort Sleeper Sofa

We have taken great care to provide you with information that is accurate and useful. Please notify us if you find an error and we will do our best to correct it. We ask that you contact us directly to confirm information about pricing, color, features, dimensions, availability and lead times.

SKU: PERRY COMFORT SLEEPER SOFA SOFA Category: Tags: , , , , , , , ,
Description

/**
* Giorgi Bros: show variable product options even when variations have no price,
* and replace the cart buttons with a “Contact us for pricing” message.
*/

// Helper: true when a variable product has no priced variations at all.
function gb_has_no_prices( $product ) {
return $product && is_a( $product, ‘WC_Product’ ) && $product->is_type( ‘variable’ )
&& empty( $product->get_variation_prices()[‘price’] );
}

// 1. Show variations even when they have no price (registered early and again before render).
function gb_show_priceless_variations() {
add_filter( ‘woocommerce_hide_invisible_variations’, ‘__return_false’, PHP_INT_MAX );
add_filter( ‘woocommerce_variation_is_visible’, ‘__return_true’, PHP_INT_MAX );
}
gb_show_priceless_variations();
add_action( ‘wp’, ‘gb_show_priceless_variations’, PHP_INT_MAX );
add_action( ‘woocommerce_before_single_product’, ‘gb_show_priceless_variations’, PHP_INT_MAX );

// 2. Don’t hide out-of-stock variations on product pages.
add_filter( ‘pre_option_woocommerce_hide_out_of_stock_items’, function ( $value ) {
return ( did_action( ‘wp’ ) && is_product() ) ? ‘no’ : $value;
} );

// 3. Put the add-to-cart form back if something removed it.
add_action( ‘woocommerce_single_product_summary’, function () {
global $product;
if ( $product && $product->is_type( ‘variable’ )
&& ! has_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’ ) ) {
woocommerce_template_single_add_to_cart();
}
}, 30 );

// 4. For variations with no price, show a contact message in place of the price.
add_filter( ‘woocommerce_available_variation’, function ( $data, $product, $variation ) {
if ( ” === $variation->get_price() ) {
$data[‘gb_no_price’] = true;
$data[‘price_html’] = ‘

Pricing for this option is available on request. ‘
. ‘Contact us or call ‘
. ‘650-588-4621.

‘;
}
return $data;
}, 20, 3 );

// 5. If no variation has a price, don’t output the quantity box, Add to Cart or Buy Now at all.
add_action( ‘woocommerce_before_single_product’, function () {
global $product;
if ( gb_has_no_prices( $product ) ) {
remove_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation_add_to_cart_button’, 20 );
}
} );
// Restore it after the main product so related products are unaffected.
add_action( ‘woocommerce_after_single_product_summary’, function () {
if ( ! has_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation_add_to_cart_button’ ) ) {
add_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation_add_to_cart_button’, 20 );
}
}, 0 );

// 6. Body class used as a CSS backup for fully priceless products.
add_filter( ‘body_class’, function ( $classes ) {
if ( is_product() && gb_has_no_prices( wc_get_product( get_queried_object_id() ) ) ) {
$classes[] = ‘gb-no-prices’;
}
return $classes;
} );

// 7. CSS in the page head so nothing flashes.
add_action( ‘wp_head’, function () {
if ( ! is_product() ) return; ?>



Additional information
Brand
ColorCream
StyleTransitional
LegsDune, Ebony, Mink, Natural Walnut, Oiled Ash
ConfigurationCot Size, Twin Size, Full Size, Queen Size, Queen Plus Size, King Size
Reviews (0)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Product Dimensions
Questions About This Product?

"*" indicates required fields

This field is for validation purposes and should be left unchanged.
Name*
What would you like to know more about?*