function dashboard_products($args = null)
 {
     global $Shopp;
     $db = DB::get();
     $defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '');
     if (!$args) {
         $args = array();
     }
     $args = array_merge($defaults, $args);
     if (!empty($args)) {
         extract($args, EXTR_SKIP);
     }
     echo $before_widget;
     echo $before_title;
     echo $widget_name;
     echo $after_title;
     $RecentBestsellers = new BestsellerProducts(array('where' => 'UNIX_TIMESTAMP(pur.created) > UNIX_TIMESTAMP()-(86400*30)', 'show' => 3));
     $RecentBestsellers->load_products();
     echo '<table><tbody><tr>';
     echo '<td><h4>' . __('Recent Bestsellers', 'Shopp') . '</h4>';
     echo '<ul>';
     foreach ($RecentBestsellers->products as $product) {
         echo '<li><a href="' . add_query_arg(array('page' => $this->Admin->editproduct, 'id' => $product->id), $Shopp->wpadminurl . "admin.php") . '">' . $product->name . '</a> (' . $product->sold . ')</li>';
     }
     echo '</ul></td>';
     $LifetimeBestsellers = new BestsellerProducts(array('show' => 3));
     $LifetimeBestsellers->load_products();
     echo '<td><h4>' . __('Lifetime Bestsellers', 'Shopp') . '</h4>';
     echo '<ul>';
     foreach ($LifetimeBestsellers->products as $product) {
         echo '<li><a href="' . add_query_arg(array('page' => $this->Admin->editproduct, 'id' => $product->id), $Shopp->wpadminurl . "admin.php") . '">' . $product->name . '</a> (' . $product->sold . ')</li>';
     }
     echo '</ul></td>';
     echo '</tr></tbody></table>';
     echo $after_widget;
 }
Ejemplo n.º 2
0
	/**
	 * Renders the bestselling products dashboard widget
	 * 
	 * @since 1.0
	 *
	 * @return void
	 **/
	function products_widget ($args=null) {
		global $Ecart;
		$db = DB::get();
		$defaults = array(
			'before_widget' => '',
			'before_title' => '',
			'widget_name' => '',
			'after_title' => '',
			'after_widget' => ''
		);

		if (!$args) $args = array();
		$args = array_merge($defaults,$args);
		if (!empty($args)) extract( $args, EXTR_SKIP );

		echo $before_widget;

		echo $before_title;
		echo $widget_name;
		echo $after_title;

		$RecentBestsellers = new BestsellerProducts(array('where'=>'UNIX_TIMESTAMP(pur.created) > UNIX_TIMESTAMP()-(86400*30)','show'=>3));
		$RecentBestsellers->load_products();

		echo '<table><tbody><tr>';
		echo '<td><h4>'.__('Recent Bestsellers','Ecart').'</h4>';
		echo '<ul>';
		if (empty($RecentBestsellers->products)) echo '<li>'.__('Nothing has been sold, yet.','Ecart').'</li>';
		foreach ($RecentBestsellers->products as $product)
			echo '<li><a href="'.add_query_arg(array('page'=>$this->pagename('products'),'id'=>$product->id),admin_url('admin.php')).'">'.$product->name.'</a> ('.$product->sold.')</li>';
		echo '</ul></td>';


		$LifetimeBestsellers = new BestsellerProducts(array('show'=>3));
		$LifetimeBestsellers->load_products();
		echo '<td><h4>'.__('Lifetime Bestsellers','Ecart').'</h4>';
		echo '<ul>';
		if (empty($LifetimeBestsellers->products)) echo '<li>'.__('Nothing has been sold, yet.','Ecart').'</li>';
		foreach ($LifetimeBestsellers->products as $product)
			echo '<li><a href="'.add_query_arg(array('page'=>$this->pagename('products'),'id'=>$product->id),admin_url('admin.php')).'">'.$product->name.'</a>'.(isset($product->sold)?' ('.$product->sold.')':' (0)').'</li>';
		echo '</ul></td>';
		echo '</tr></tbody></table>';
		echo $after_widget;

	}