Astra_Woocommerce::astra_woo_is_subcategory( int $category_id = null )
Check if the current page is a Product Subcategory page or not.
Description
Parameters
- $category_id
-
(int) (Optional) Current page Category ID.
Default value: null
Return
(bool)
Source
File: inc/compatibility/woocommerce/class-astra-woocommerce.php
public function astra_woo_is_subcategory( $category_id = null ) {
if ( is_tax( 'product_cat' ) ) {
if ( empty( $category_id ) ) {
$category_id = get_queried_object_id();
}
$category = get_term( get_queried_object_id(), 'product_cat' );
if ( empty( $category->parent ) ) {
return false;
}
return true;
}
return false;
}
Expand full source code Collapse full source code View on Trac