filters all of the theme api results for a particular object context.

add_filter( 'shopp_themeapi_{object}', [callback] )

@param mixed $result the theme api call results
@param array $options the options array passed to the theme api call
@param string $tag the tag name of the theme api call
@param Object $Object the Object subject of the theme api call


filters all of the theme api results for a particular object context.

Examples built-in filters:

  • shopp_themeapi_customer – filters all shopp(‘customer’) theme api call results
  • shopp_themeapi_catalog – filters all shopp(‘catalog’) theme api call results
  • shopp_themeapi_category – filters all shopp(‘category’) theme api call results
  • shopp_themeapi_product – filters all shopp(‘product’) theme api call results
  • shopp_themeapi_cart – filters all shopp(‘cart’) theme api call results
  • shopp_themeapi_cartitem – filters all shopp(‘cartitem’) theme api call results
  • shopp_themeapi_checkout – filters all shopp(‘checkout’) theme api call results
  • shopp_themeapi_purchase – filters all shopp(‘purchase’) theme api call results
  • shopp_themeapi_shipping – filters all shopp(‘shipping’) theme api call results

The object portion of the shopp_themeapi_{object} dynamic filter is set by the string passed as the first argument to the shopp() theme api call. So in addition to the above built-in calls, you can specify your own object context name, for your own custom theme api context. In Shopp 1.2, the first argument to the shopp() api call can be an Object, in which case the object context name for this filter will be set by either a public api property of your object, or by the lower-case classname of the object.

This filter is useful for overriding the results for an existing theme api call, or for extended the theme api for your own tags on Shopp objects, or tags on custom objects.

If you only need to over-ride a single tag, you can also use one of the shopp_themeapi_{object}_{tag} dynamic filters.


// register filter callback
// add_filter('shopp_themeapi_{object}', 'my_fltr');

// if your theme api filter needs to override the default result
// set the priority of your filter lower (11 or bigger), so that it will run *after* Shopp's
add_filter('shopp_themeapi_product', 'my_product_themeapi_fltr', 11, 4);

// silly example
function my_product_themeapi_fltr( $result, $options, $tag, $Product ) {
    // Say I want to override the shopp('product', 'image') theme api call
    // for only Product 10, to display a random image
    if ( 10 == $Product->id && 'image' == $tag ) {      
        if ( ! isset($options['src']) ) return $result;
        $i = rand(0, count($Product->images));
        $id = $Product->images[$i]->id;
        $options['id'] = $id;

        // the get- prefix in the tag is Shopp 1.2 short-hand for the return=true option
        return shopp('product', 'get-image', $options);
    return $result;

See Also

You must be logged in to post a comment.

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