Exemple #1
0
 public function __construct($id = false, $key = 'id', $taxonomy = false)
 {
     $this->taxonomy = $taxonomy ? $taxonomy : self::$taxon;
     parent::__construct($id, $key);
 }
Exemple #2
0
 /**
  * Register custom taxonomies
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return void
  **/
 public function taxonomies()
 {
     ProductTaxonomy::register('ProductCategory');
     ProductTaxonomy::register('ProductTag');
 }
Exemple #3
0
/**
 * Get a list of product objects for the given term and taxonomy
 *
 * @api
 * @since 1.2
 *
 * @param int $term (required) The term id
 * @param string $taxonomy The taxonomy name
 * @param array $options loading options
 * @return array Product objects
 **/
function shopp_term_products($term = false, $taxonomy = 'shopp_category', $options = array())
{
    $defaults = array('limit' => 1000, 'debug' => false);
    $options = wp_parse_args($options, $defaults);
    if (!taxonomy_exists($taxonomy) || !in_array($taxonomy, get_object_taxonomies(ShoppProduct::$posttype))) {
        shopp_debug(__FUNCTION__ . " failed: Invalid Shopp taxonomy {$taxonomy}.");
        return false;
    }
    if (!($term = term_exists($term, $taxonomy))) {
        shopp_debug(__FUNCTION__ . " failed: {$term} not a valid Shopp {$taxonomy} term.");
        return false;
    }
    $Tax = new ProductTaxonomy();
    $Tax->id = $term['term_id'];
    $Tax->term_taxonomy_id = $term['term_taxonomy_id'];
    $Tax->taxonomy = $taxonomy;
    $Tax->load($options);
    return !empty($Tax->products) ? $Tax->products : array();
}