is_rest_api_request() && empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) { return false; } $rest_route = $GLOBALS['wp']->query_vars['rest_route']; return ( false !== strpos( $rest_route, 'wc/store/cart' ) || false !== strpos( $rest_route, 'wc/store/checkout' ) ); } /** * Check if current page has woocommerce cart or checkout block. * * @return bool */ public static function has_cart_or_checkout_block() { $page = get_post(); if ( ! $page ) { return false; } $blocks = parse_blocks( $page->post_content ); if ( ! $blocks ) { return false; } foreach ( $blocks as $block ) { $block_name = $block['blockName']; if ( 'woocommerce/cart' === $block_name || 'woocommerce/checkout' === $block_name ) { return true; } } return false; } /** * Checks whether the current user has permissions to manage shipping labels. * * @return boolean */ public static function user_can_manage_labels() { /** * @since 1.25.14 */ return apply_filters( 'wcship_user_can_manage_labels', current_user_can( 'manage_woocommerce' ) || current_user_can( 'wcship_manage_labels' ) ); } } }