Introduce woocommerce_product_loop helper
This commit is contained in:
parent
823332b5db
commit
6d76cb71fd
|
@ -224,6 +224,18 @@ function wc_set_loop_prop( $prop, $value = '' ) {
|
||||||
$GLOBALS['woocommerce_loop'][ $prop ] = $value;
|
$GLOBALS['woocommerce_loop'][ $prop ] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the WooCommerce loop be displayed?
|
||||||
|
*
|
||||||
|
* This will return true if we have posts (products) or if we have subcats to display.
|
||||||
|
*
|
||||||
|
* @since 3.4.0
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function woocommerce_product_loop() {
|
||||||
|
return have_posts() || 'products' !== woocommerce_get_loop_display_mode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output generator tag to aid debugging.
|
* Output generator tag to aid debugging.
|
||||||
*
|
*
|
||||||
|
@ -551,7 +563,7 @@ if ( ! function_exists( 'woocommerce_content' ) ) {
|
||||||
|
|
||||||
<?php do_action( 'woocommerce_archive_description' ); ?>
|
<?php do_action( 'woocommerce_archive_description' ); ?>
|
||||||
|
|
||||||
<?php if ( have_posts() ) : ?>
|
<?php if ( woocommerce_product_loop() ) : ?>
|
||||||
|
|
||||||
<?php do_action( 'woocommerce_before_shop_loop' ); ?>
|
<?php do_action( 'woocommerce_before_shop_loop' ); ?>
|
||||||
|
|
||||||
|
@ -1833,7 +1845,7 @@ if ( ! function_exists( 'woocommerce_maybe_show_product_subcategories' ) ) {
|
||||||
* @param string $loop_html HTML.
|
* @param string $loop_html HTML.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function woocommerce_maybe_show_product_subcategories( $loop_html ) {
|
function woocommerce_maybe_show_product_subcategories( $loop_html = '' ) {
|
||||||
if ( wc_get_loop_prop( 'is_shortcode' ) && ! WC_Template_Loader::in_content_filter() ) {
|
if ( wc_get_loop_prop( 'is_shortcode' ) && ! WC_Template_Loader::in_content_filter() ) {
|
||||||
return $loop_html;
|
return $loop_html;
|
||||||
}
|
}
|
||||||
|
@ -2582,7 +2594,7 @@ if ( ! function_exists( 'woocommerce_account_edit_account' ) ) {
|
||||||
if ( ! function_exists( 'wc_no_products_found' ) ) {
|
if ( ! function_exists( 'wc_no_products_found' ) ) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show no products found message.
|
* Handles the loop when no products were found/no product exist.
|
||||||
*/
|
*/
|
||||||
function wc_no_products_found() {
|
function wc_no_products_found() {
|
||||||
wc_get_template( 'loop/no-products-found.php' );
|
wc_get_template( 'loop/no-products-found.php' );
|
||||||
|
|
|
@ -10,15 +10,12 @@
|
||||||
* happen. When this occurs the version of the template file will be bumped and
|
* happen. When this occurs the version of the template file will be bumped and
|
||||||
* the readme will list any important changes.
|
* the readme will list any important changes.
|
||||||
*
|
*
|
||||||
* @see https://docs.woocommerce.com/document/template-structure/
|
* @see https://docs.woocommerce.com/document/template-structure/
|
||||||
* @author WooThemes
|
* @package WooCommerce/Templates
|
||||||
* @package WooCommerce/Templates
|
* @version 3.4.0
|
||||||
* @version 3.3.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
defined( 'ABSPATH' ) || exit;
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
get_header( 'shop' );
|
get_header( 'shop' );
|
||||||
|
|
||||||
|
@ -48,8 +45,7 @@ do_action( 'woocommerce_before_main_content' );
|
||||||
?>
|
?>
|
||||||
</header>
|
</header>
|
||||||
<?php
|
<?php
|
||||||
|
if ( woocommerce_product_loop() ) {
|
||||||
if ( have_posts() ) {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook: woocommerce_before_shop_loop.
|
* Hook: woocommerce_before_shop_loop.
|
||||||
|
|
Loading…
Reference in New Issue