Skip to content

Commit d0279fe

Browse files
authored
Add compatibility with WooCommerce Coming Soon (#2204)
1 parent f0cfe83 commit d0279fe

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

inc/woocommerce/storefront-woocommerce-template-functions.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@
88
if ( ! function_exists( 'storefront_woo_cart_available' ) ) {
99
/**
1010
* Validates whether the Woo Cart instance is available in the request
11+
* Will also be `false` for logged-out users if the Coming Soon mode is enabled for store pages only.
1112
*
1213
* @since 2.6.0
1314
* @return bool
1415
*/
1516
function storefront_woo_cart_available() {
17+
$coming_soon_helper_class = \Automattic\WooCommerce\Internal\ComingSoon\ComingSoonHelper::class;
18+
if ( function_exists( 'wc_get_container' ) && class_exists( $coming_soon_helper_class ) ) {
19+
$coming_soon_helper = wc_get_container()->get( $coming_soon_helper_class );
20+
if ( ! is_user_logged_in() && $coming_soon_helper->is_store_coming_soon() ) {
21+
return false;
22+
}
23+
}
24+
1625
$woo = WC();
1726
return $woo instanceof \WooCommerce && $woo->cart instanceof \WC_Cart;
1827
}

0 commit comments

Comments
 (0)