/** * Checks if the storefront has any categories * * @api `shopp('storefront.has-categories')` * @since 1.1 * * @param string $result The output * @param array $options The options * - **showsmart**: (before,after) Include smart collections before or after the categories * @param ShoppStorefront $O The working object * @return bool True if categories exist, false otherwise **/ public static function has_categories($result, $options, $O) { $defaults = array('showsmart' => false); $options = array_merge($defaults, $options); extract($options, EXTR_SKIP); if (empty($O->categories)) { $O->load_categories($options, $showsmart); } else { // Make sure each entry is a valid ProductCollection to prevent fatal errors @bug #2017 foreach ($O->categories as $id => $term) { if ($Category instanceof ProductCollection) { continue; } $ProductCategory = new ProductCategory(); $ProductCategory->populate($term); $O->categories[$id] = $ProductCategory; } reset($O->categories); return true; } reset($O->categories); return count($O->categories) > 0; }
public function load_category($term, $taxonomy) { $Category = new ProductCategory(); $Category->populate($term); return $Category; }