is_shopp_collection()

determines if the current request is for a registered dynamic Shopp collection

is_shopp_collection ()

@return bool true if current page request is for a Shopp product collection, else false.

Description

determines if the current request is for a registered dynamic Shopp collection

This function will not identify PHP loaded collections. It only evaluates the current page request, meaning using is_shopp_collection() on the catalog landing page, even when the landing page (catalog.php) template loads the CatalogProducts collection will return false, because CatalogProducts is loaded in the template and not directly from the request. Use is_shopp_catalog() instead to determine of your are viewing the catalog landing page.

Also note that Shopp product taxonomies are not “collections” from the perspective of this function, as they are not registered as collections using the shopp_register_collection() function. Product taxonomy requests are handled differently. If the collection can not be queried through the ordinary WordPress API as a taxonomy, it is not a product taxonomy. Taxonomies are handled through a separate is_shopp_taxonomy() function.

For example, see the list below of built-in collections in Shopp 1.2 that are not also classified as product taxonomies:

  • Catalog Products – collection of all products in the catalog.
  • New Products – collection of product recently published.
  • Featured Products – collection of products marked featured.
  • On Sale Products – collection of products with sale prices.
  • Bestseller Products – collection of best selling products in the store.
  • Search Results – collection built from a catalog search.
  • Tag Products – the smart collection loaded by tag (in this case there is also a shopp product taxonomy shopp_tag with can be loaded as a taxonomy page request)
  • Related Products – collection of products related to the current product (or a specified product)
  • Also Bought Products – collection of products associated with the current product in the store’s purchase history
  • Viewed Products – colleciton of products viewed by the current customer (in this session)
  • Random Products – a random collection of products
  • Promo Products – collection of products that currently have catalog promotions (not cart promotions)

When this function returns true, a call to ShoppCollection() will return the requested Collection object. Also, because the global product context is set by the page request, shopp(‘collection’) or shopp(‘category’) theme api calls can be used safely when this function returns true.

Example

if ( is_shopp_collection() ) {
    // do collection specific code
}

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar