本文整理汇总了PHP中ShoppDatabaseObject类的典型用法代码示例。如果您正苦于以下问题:PHP ShoppDatabaseObject类的具体用法?PHP ShoppDatabaseObject怎么用?PHP ShoppDatabaseObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShoppDatabaseObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$this->name = __('Database', 'Shopp');
$this->_table = ShoppDatabaseObject::tablename($this->_table);
$this->_metatable = ShoppDatabaseObject::tablename($this->_metatable);
}
开发者ID:crunnells,项目名称:shopp,代码行数:7,代码来源:DBStorage.php
示例2: screen
public function screen()
{
if (!current_user_can('shopp_promotions')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$table = ShoppDatabaseObject::tablename(ShoppPromo::$table);
$defaults = array('page' => false, 'status' => false, 'type' => false, 'paged' => 1, 'per_page' => 20, 's' => '');
$args = array_merge($defaults, $_GET);
extract($args, EXTR_SKIP);
$url = add_query_arg(array_merge($_GET, array('page' => $this->page)), admin_url('admin.php'));
$f = array('action', 'selected', 's');
$url = remove_query_arg($f, $url);
$pagenum = absint($paged);
$start = $per_page * ($pagenum - 1);
$where = array();
if (!empty($s)) {
$where[] = "name LIKE '%{$s}%'";
}
if ($status) {
$datesql = ShoppPromo::activedates();
switch (strtolower($status)) {
case 'active':
$where[] = "status='enabled' AND {$datesql}";
break;
case 'inactive':
$where[] = "status='enabled' AND NOT {$datesql}";
break;
case 'enabled':
$where[] = "status='enabled'";
break;
case 'disabled':
$where[] = "status='disabled'";
break;
}
}
if ($type) {
switch (strtolower($type)) {
case 'catalog':
$where[] = "target='Catalog'";
break;
case 'cart':
$where[] = "target='Cart'";
break;
case 'cartitem':
$where[] = "target='Cart Item'";
break;
}
}
$select = sDB::select(array('table' => $table, 'columns' => 'SQL_CALC_FOUND_ROWS *', 'where' => $where, 'orderby' => 'created DESC', 'limit' => "{$start},{$per_page}"));
$Promotions = sDB::query($select, 'array');
$count = sDB::found();
$num_pages = ceil($count / $per_page);
$ListTable = ShoppUI::table_set_pagination($this->id, $count, $num_pages, $per_page);
$states = array('active' => __('Active', 'Shopp'), 'inactive' => __('Not Active', 'Shopp'), 'enabled' => __('Enabled', 'Shopp'), 'disabled' => __('Disabled', 'Shopp'));
$types = array('catalog' => __('Catalog Discounts', 'Shopp'), 'cart' => __('Cart Discounts', 'Shopp'), 'cartitem' => __('Cart Item Discounts', 'Shopp'));
$num_pages = ceil($count / $per_page);
$page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => $num_pages, 'current' => $pagenum));
include $this->ui('discounts.php');
}
开发者ID:msigley,项目名称:shopp,代码行数:59,代码来源:Discounts.php
示例3: query
function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) as period,\n\t\t\t\t\t\t\tSUM( ( SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase ) ) AS items,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) as subtotal,\n\t\t\t\t\t\t\tSUM(o.discount) as discounts\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:12,代码来源:discounts.php
示例4: query
function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed', 'captured', 'CHARGED')";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) AS period,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) AS subtotal,\n\t\t\t\t\t\t\tSUM(o.tax) AS tax,\n\t\t\t\t\t\t\tSUM(o.freight) AS shipping,\n\t\t\t\t\t\t\tSUM(o.discount) AS discounts,\n\t\t\t\t\t\t\tSUM(o.total) AS total,\n\t\t\t\t\t\t\tAVG(o.total) AS orderavg,\n\t\t\t\t\t\t\tSUM( (SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase) ) AS items,\n\t\t\t\t\t\t\t(SELECT AVG(p.unitprice) FROM {$purchased_table} AS p WHERE o.id = p.purchase) AS itemavg\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:13,代码来源:sales.php
示例5: query
public function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed', 'captured', 'CHARGED')";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) as period,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) as subtotal,\n\t\t\t\t\t\t\tSUM(o.tax) as tax,\n\t\t\t\t\t\t\tSUM(p1.taxable) as taxable,\n\t\t\t\t\t\t\tAVG(p2.rate) as rate\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tLEFT JOIN (SELECT purchase, SUM(p.total) as taxable FROM {$purchased_table} AS p WHERE p.unittax > 0 GROUP BY purchase) p1 ON p1.purchase = o.id\n\t\t\t\t\tLEFT JOIN (SELECT purchase, AVG(p.unittax/p.unitprice) as rate FROM {$purchased_table} AS p WHERE p.unittax > 0 GROUP BY purchase) p2 ON p2.purchase = o.id\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
开发者ID:crunnells,项目名称:shopp,代码行数:13,代码来源:tax.php
示例6: screen
public function screen()
{
$Shopp = Shopp::object();
if (!current_user_can('shopp_settings_checkout')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
$next_setting = shopp_setting('next_order_id');
if ($next->id > $next_setting) {
$next_setting = $next->id;
}
$term_recount = false;
if (!empty($_POST['save'])) {
check_admin_referer('shopp-setup-management');
$next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
if ($next_order_id >= $next->id) {
if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
$next_setting = $next_order_id;
}
}
$_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
// Recount terms when this setting changes
if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
$term_recount = true;
}
shopp_set_formsettings();
$this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
}
if ($term_recount) {
$taxonomy = ProductCategory::$taxon;
$terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
if (!empty($terms)) {
wp_update_term_count_now($terms, $taxonomy);
}
}
$states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
$statusLabels = shopp_setting('order_status');
$statesLabels = shopp_setting('order_states');
$reasonLabels = shopp_setting('cancel_reasons');
if (empty($reasonLabels)) {
$reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
}
$promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
$lowstock = shopp_setting('lowstock_level');
if (empty($lowstock)) {
$lowstock = 0;
}
include $this->ui('management.php');
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:50,代码来源:OrdersSettings.php
示例7: shopp_orders
/**
* shopp_orders - get a list of purchases
*
* @api
* @since 1.2
*
* @param mixed $from (optional) mktime or SQL datetime, get purchases after this date/time.
* @param mixed $to (optional) mktime or SQL datetime, get purchased before this date/time.
* @param bool $items (optional default:true) load purchased items into the records, slightly slower operation
* @param array $customers (optional) list of int customer ids to limit the purchases to. All customers by default.
* @param int $limit (optional default:false) maximimum number of results to get, false for no limit
* @param string $order (optional default:DESC) DESC or ASC, for sorting in ascending or descending order.
* @param string $orderby (optional) The column used to sort records
* @param bool $paidonly (optional) Restrict to orders where payment has been completed
* @param bool $downloads (optional) Restrict to orders that have downloads
* @return array of Purchase objects
**/
function shopp_orders($from = false, $to = false, $items = true, array $customers = array(), $limit = false, $order = 'DESC', $orderby = 'id', $paidonly = false, $downloads = false)
{
$pt = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$pd = ShoppDatabaseObject::tablename(ShoppPurchased::$table);
$op = '<';
$where = array();
$dateregex = '/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/';
foreach (array($from, $to) as $datetime) {
if (!$datetime) {
continue;
}
if (1 == preg_match($dateregex, $datetime)) {
$where[] = "'{$datetime}' {$op} p.created";
} else {
if (is_int($datetime)) {
$where[] = "FROM_UNIXTIME({$datetime}) {$op} p.created";
}
}
$op = '>=';
}
if (!empty($customers)) {
$set = sDB::escape(implode(',', $customers));
$where[] = "0 < FIND_IN_SET(p.customer,'" . $set . "')";
}
if ($paidonly) {
$where[] = "p.txnstatus='captured'";
}
if ($items && $downloads) {
$where[] = " pd.download > 0";
}
$where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where);
if ((int) $limit > 0) {
$limit = " LIMIT {$limit}";
} else {
$limit = '';
}
if (!in_array(strtolower($orderby), array('id', 'created', 'modified'))) {
$orderby = 'id';
}
if ($items) {
$query = "SELECT pd.* FROM {$pd} AS pd INNER JOIN {$pt} AS p ON pd.purchase = p.id {$where} " . $limit;
$purchased = sDB::query($query, 'array', '_shopp_order_purchased');
$orders = sDB::query("SELECT * FROM {$pt} WHERE FIND_IN_SET(id,'" . join(',', array_keys($purchased)) . "') ORDER BY {$orderby} " . ('DESC' == $order ? 'DESC' : 'ASC'), 'array', '_shopp_order_purchase', $purchased);
} else {
$query = "SELECT * FROM {$pt} AS p {$where} ORDER BY {$orderby} " . ('DESC' == $order ? 'DESC' : 'ASC') . $limit;
$orders = sDB::query($query, 'array', '_shopp_order_purchase');
}
return $orders;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:66,代码来源:order.php
示例8: query
function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed','captured')";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = "o.cardtype";
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchase_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:20,代码来源:payment-types.php
示例9: query
function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = 'c.id';
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$customer_table = ShoppDatabaseObject::tablename('customer');
$query = "SELECT {$id} AS id,\n\t\t\t\t\t\t\tCONCAT(c.firstname,' ',c.lastname) AS customer,\n\t\t\t\t\t\t\tSUM( (SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase) ) AS sold,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchase_table} as o\n\t\t\t\t\tINNER JOIN {$customer_table} AS c ON c.id=o.customer\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY {$id} ORDER BY {$ordercols}";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:21,代码来源:customers.php
示例10: query
function query()
{
$this->options = array_merge(array('orderby' => '(pr.stock/pr.stocked)', 'order' => 'ASC'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "pr.inventory='on'";
$where = join(" AND ", $where);
if (!in_array(strtoupper($order), array('ASC', 'DESC'))) {
$order = 'DESC';
}
if (!in_array(strtolower($orderby), array('inventory'))) {
$orderby = '(pr.stock/pr.stocked)';
}
$ordercols = "{$orderby} {$order}";
$id = "pr.product,' ',pr.id";
$product_table = WPDatabaseObject::tablename(ShoppProduct::$table);
$summary_table = ShoppDatabaseObject::tablename(ProductSummary::$table);
$price_table = ShoppDatabaseObject::tablename('price');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCONCAT(p.post_title,' ',pr.label) AS product,\n\t\t\t\t\t\t\tpr.stock AS inventory,\n\t\t\t\t\t\t\tpr.stocked AS stocked,\n\t\t\t\t\t\t\t(pr.stock/pr.stocked)*100 AS level\n\t\t\t\t\tFROM {$price_table} AS pr\n\t\t\t\t\tJOIN {$product_table} AS p ON p.ID=pr.product\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:21,代码来源:inventory.php
示例11: query
public function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "orders.txnstatus IN ('authed','captured')";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = "o.product,' ',o.price";
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$product_table = WPDatabaseObject::tablename(ShoppProduct::$table);
$price_table = ShoppDatabaseObject::tablename('price');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCONCAT(p.post_title,' ', IF(pr.context != 'product',pr.label,'')) AS product,\n\t\t\t\t\t\t\tpr.sku as sku,\n\t\t\t\t\t\t\tSUM(o.quantity) AS sold,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.purchase) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchased_table} AS o INNER JOIN {$purchase_table} AS orders ON orders.id=o.purchase\n\t\t\t\t\tJOIN {$product_table} AS p ON p.ID=o.product\n\t\t\t\t\tJOIN {$price_table} AS pr ON pr.id=o.price\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:23,代码来源:products.php
示例12: query
public function query($request = array())
{
$defaults = array('status' => false, 's' => false, 'start' => false, 'end' => false);
$request = array_merge($defaults, $_GET);
extract($request);
if (!empty($start)) {
list($month, $day, $year) = explode('/', $start);
$start = mktime(0, 0, 0, $month, $day, $year);
}
if (!empty($end)) {
list($month, $day, $year) = explode('/', $end);
$end = mktime(23, 59, 59, $month, $day, $year);
}
$where = array();
$joins = array();
if (!empty($status) || $status === '0') {
$where[] = "status='" . sDB::escape($status) . "'";
}
if (!empty($s)) {
$s = stripslashes($s);
$search = array();
if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER) > 0) {
foreach ($props as $query) {
$keyword = sDB::escape(!empty($query[2]) ? $query[2] : $query[3]);
switch (strtolower($query[1])) {
case "txn":
$search[] = "txnid='{$keyword}'";
break;
case "company":
$search[] = "company LIKE '%{$keyword}%'";
break;
case "gateway":
$search[] = "gateway LIKE '%{$keyword}%'";
break;
case "cardtype":
$search[] = "cardtype LIKE '%{$keyword}%'";
break;
case "address":
$search[] = "(address LIKE '%{$keyword}%' OR xaddress='%{$keyword}%')";
break;
case "city":
$search[] = "city LIKE '%{$keyword}%'";
break;
case "province":
case "state":
$search[] = "state='{$keyword}'";
break;
case "zip":
case "zipcode":
case "postcode":
$search[] = "postcode='{$keyword}'";
break;
case "country":
$search[] = "country='{$keyword}'";
break;
case "promo":
case "discount":
$meta_table = ShoppDatabaseObject::tablename(ShoppMetaObject::$table);
$joins[$meta_table] = "INNER JOIN {$meta_table} AS discounts ON discounts.parent = o.id AND discounts.name='discounts' AND discounts.context='purchase'";
$search[] = "discounts.value LIKE '%{$keyword}%'";
break;
}
}
if (empty($search)) {
$search[] = "(o.id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')";
}
$where[] = "(" . join(' OR ', $search) . ")";
} elseif (strpos($s, '@') !== false) {
$where[] = "email='" . sDB::escape($s) . "'";
} else {
$where[] = "(o.id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%" . sDB::escape($s) . "%')";
}
}
if (!empty($start) && !empty($end)) {
$where[] = '(UNIX_TIMESTAMP(o.created) >= ' . $start . ' AND UNIX_TIMESTAMP(o.created) <= ' . $end . ')';
}
if (!empty($customer)) {
$where[] = "customer=" . intval($customer);
}
$where = !empty($where) ? "WHERE " . join(' AND ', $where) : '';
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$purchasedtable = ShoppDatabaseObject::tablename(ShoppPurchased::$table);
$offset = $this->set * $this->limit;
$c = 0;
$columns = array();
$purchasedcols = false;
$discountcols = false;
$addoncols = false;
foreach ($this->selected as $column) {
$columns[] = "{$column} AS col" . $c++;
if (false !== strpos($column, 'p.')) {
$purchasedcols = true;
}
if (false !== strpos($column, 'discounts')) {
$discountcols = true;
}
if (false !== strpos($column, 'addons')) {
$addoncols = true;
}
}
//.........这里部分代码省略.........
开发者ID:borkweb,项目名称:shopp,代码行数:101,代码来源:Purchase.php
示例13: inventory_widget
/**
* Renders the bestselling products dashboard widget
*
* @author Jonathan Davis
* @since 1.0
*
* @return void
**/
public static function inventory_widget($args = false)
{
$warnings = array('none' => __('OK', 'Shopp'), 'warning' => __('warning', 'Shopp'), 'critical' => __('critical', 'Shopp'), 'backorder' => __('backorder', 'Shopp'));
$defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '');
$args = array_merge($defaults, (array) $args);
extract($args, EXTR_SKIP);
$pt = ShoppDatabaseObject::tablename(ShoppPrice::$table);
$setting = shopp_setting('lowstock_level');
$where = array();
$where[] = "pt.stock < pt.stocked AND pt.stock/pt.stocked < {$setting}";
$where[] = "(pt.context='product' OR pt.context='variation') AND pt.type != 'N/A'";
$loading = array('columns' => "pt.id AS stockid,IF(pt.context='variation',CONCAT(p.post_title,': ',pt.label),p.post_title) AS post_title,pt.sku AS sku,pt.stock,pt.stocked", 'joins' => array($pt => "LEFT JOIN {$pt} AS pt ON p.ID=pt.product"), 'where' => $where, 'groupby' => 'pt.id', 'orderby' => '(pt.stock/pt.stocked) ASC', 'published' => false, 'pagination' => false, 'limit' => 25);
$Collection = new ProductCollection();
$Collection->load($loading);
$productscreen = add_query_arg(array('page' => ShoppAdmin::pagename('products')), admin_url('admin.php'));
echo $before_widget;
echo $before_title;
echo $widget_name;
echo $after_title;
?>
<table><tbody>
<?php
foreach ($Collection->products as $product) {
$product->lowstock($product->stock, $product->stocked);
?>
<tr>
<td class="amount"><?php
echo abs($product->stock);
?>
</td>
<td><span class="stock lowstock <?php
echo $product->lowstock;
?>
"><?php
echo $warnings[$product->lowstock];
?>
</span></td>
<td><a href="<?php
echo esc_url(add_query_arg('id', $product->id, $productscreen));
?>
"><?php
echo $product->name;
?>
</a></td>
<td><a href="<?php
echo esc_url(add_query_arg('view', 'inventory', $productscreen));
?>
"><?php
echo $product->sku;
?>
</a></td>
</tr>
<?php
}
?>
</tbody></table>
<?php
echo $after_widget;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:68,代码来源:Dashboard.php
示例14: management
public function management()
{
$Shopp = Shopp::object();
if (!current_user_can('shopp_settings_checkout')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
$next_setting = shopp_setting('next_order_id');
if ($next->id > $next_setting) {
$next_setting = $next->id;
}
if (!empty($_POST['save'])) {
check_admin_referer('shopp-setup-management');
$next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
if ($next_order_id >= $next->id) {
if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
$next_setting = $next_order_id;
}
}
shopp_set_formsettings();
$this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
}
$states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
$statusLabels = shopp_setting('order_status');
$statesLabels = shopp_setting('order_states');
$reasonLabels = shopp_setting('cancel_reasons');
if (empty($reasonLabels)) {
$reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
}
include $this->ui('management.php');
}
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:32,代码来源:Setup.php
示例15: loadby_dkey
public function loadby_dkey($key)
{
$pricetable = ShoppDatabaseObject::tablename(ShoppPrice::$table);
$Purchased = new ShoppPurchased($key, 'dkey');
if (!empty($Purchased->id)) {
// Handle purchased line-item downloads
$Purchase = new ShoppPurchase($Purchased->purchase);
$record = sDB::query("SELECT download.* FROM {$this->_table} AS download INNER JOIN {$pricetable} AS pricing ON pricing.id=download.parent WHERE pricing.id={$Purchased->price} AND download.context='price' AND download.type='download' ORDER BY modified DESC LIMIT 1");
$this->populate($record);
$this->expopulate();
$this->purchased = $Purchased->id;
} else {
// Handle purchased line-item meta downloads (addon downloads)
$this->load(array('context' => 'purchased', 'type' => 'download', 'name' => $key));
$this->expopulate();
$this->purchased = $this->parent;
}
$this->etag = $key;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:19,代码来源:Asset.php
示例16: __construct
function __construct($parent = false, $context = 'product', $type = false, $sort = 'sortorder')
{
$this->_table = ShoppDatabaseObject::tablename(self::$table);
$params = array('parent' => $parent, 'context' => $context);
if ($type !== false) {
$params['type'] = $type;
}
if ($parent !== false) {
$this->load($params);
}
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:11,代码来源:Meta.php
示例17: loader
public function loader($workflow = false)
{
if (!current_user_can('shopp_products')) {
return;
}
add_screen_option('per_page', array('label' => __('Products Per Page', 'Shopp'), 'default' => 20, 'option' => 'edit_' . ShoppProduct::$posttype . '_per_page'));
$per_page_option = get_current_screen()->get_option('per_page');
$defaults = array('cat' => false, 'paged' => 1, 'per_page' => $per_page_option['default'], 's' => '', 'sl' => '', 'matchcol' => '', 'view' => $this->view, 'is_inventory' => false, 'is_trash' => false, 'is_bestselling' => false, 'categories_menu' => false, 'inventory_menu' => false, 'lowstock' => 0, 'columns' => '', 'orderby' => '', 'order' => '', 'where' => array(), 'joins' => array());
$args = array_merge($defaults, $_GET);
if (false !== ($user_per_page = get_user_option($per_page_option['option']))) {
$args['per_page'] = $user_per_page;
}
extract($args, EXTR_SKIP);
$url = ShoppAdminController::url($_GET);
$subs = array('all' => array('label' => Shopp::__('All'), 'where' => array("p.post_status!='trash'")), 'published' => array('label' => Shopp::__('Published'), 'where' => array("p.post_status='publish'")), 'drafts' => array('label' => Shopp::__('Drafts'), 'where' => array("p.post_status='draft'")), 'onsale' => array('label' => Shopp::__('On Sale'), 'where' => array("s.sale='on' AND p.post_status != 'trash'")), 'featured' => array('label' => Shopp::__('Featured'), 'where' => array("s.featured='on' AND p.post_status != 'trash'")), 'bestselling' => array('label' => Shopp::__('Bestselling'), 'where' => array("p.post_status!='trash'", BestsellerProducts::threshold() . " < s.sold"), 'order' => 'bestselling'), 'inventory' => array('label' => Shopp::__('Inventory'), 'where' => array("s.inventory='on' AND p.post_status != 'trash'")), 'trash' => array('label' => Shopp::__('Trash'), 'where' => array("p.post_status='trash'")));
if (!shopp_setting_enabled('inventory')) {
unset($subs['inventory']);
}
switch ($view) {
case 'inventory':
if (shopp_setting_enabled('inventory')) {
$is_inventory = true;
} else {
Shopp::redirect(add_query_arg('view', null, $url), true);
}
break;
case 'trash':
$is_trash = true;
break;
case 'bestselling':
$is_bestselling = true;
break;
}
if ($is_inventory) {
$per_page = 50;
}
$pagenum = absint($paged);
$start = $per_page * ($pagenum - 1);
$where = $subs[$this->view]['where'];
if (!empty($s)) {
$SearchResults = new SearchResults(array('search' => $s, 'nostock' => 'on', 'published' => 'off', 'paged' => -1));
$SearchResults->load();
$ids = array_keys($SearchResults->products);
$where[] = "p.ID IN (" . join(',', $ids) . ")";
}
if (!empty($cat)) {
global $wpdb;
$joins[$wpdb->term_relationships] = "INNER JOIN {$wpdb->term_relationships} AS tr ON (p.ID=tr.object_id)";
$joins[$wpdb->term_taxonomy] = "INNER JOIN {$wpdb->term_taxonomy} AS tt ON (tr.term_taxonomy_id=tt.term_taxonomy_id AND tt.term_id={$cat})";
if (-1 == $cat) {
unset($joins[$wpdb->term_taxonomy]);
$joins[$wpdb->term_relationships] = "LEFT JOIN {$wpdb->term_relationships} AS tr ON (p.ID=tr.object_id)";
$where[] = 'tr.object_id IS NULL';
}
}
// Detect custom taxonomies
$taxonomies = array_intersect(get_object_taxonomies(ShoppProduct::$posttype), array_keys($_GET));
if (!empty($taxonomies)) {
foreach ($taxonomies as $n => $taxonomy) {
global $wpdb;
$term = get_term_by('slug', $_GET[$taxonomy], $taxonomy);
if (!empty($term->term_id)) {
$joins[$wpdb->term_relationships . '_' . $n] = "INNER JOIN {$wpdb->term_relationships} AS tr{$n} ON (p.ID=tr{$n}.object_id)";
$joins[$wpdb->term_taxonomy . '_' . $n] = "INNER JOIN {$wpdb->term_taxonomy} AS tt{$n} ON (tr{$n}.term_taxonomy_id=tt{$n}.term_taxonomy_id AND tt{$n}.term_id={$term->term_id})";
}
}
}
if (!empty($sl) && shopp_setting_enabled('inventory')) {
switch ($sl) {
case "ns":
foreach ($where as &$w) {
$w = str_replace("s.inventory='on'", "s.inventory='off'", $w);
}
$where[] = "s.inventory='off'";
break;
case "oos":
$where[] = "(s.inventory='on' AND s.stock = 0)";
break;
case "ls":
$ls = shopp_setting('lowstock_level');
if (empty($ls)) {
$ls = '0';
}
$where[] = "(s.inventory='on' AND s.lowstock != 'none')";
break;
case "is":
$where[] = "(s.inventory='on' AND s.stock > 0)";
}
}
$lowstock = shopp_setting('lowstock_level');
// Setup queries
$pd = WPDatabaseObject::tablename(ShoppProduct::$table);
$pt = ShoppDatabaseObject::tablename(ShoppPrice::$table);
$ps = ShoppDatabaseObject::tablename(ProductSummary::$table);
$orderdirs = array('asc', 'desc');
if (in_array($order, $orderdirs)) {
$orderd = strtolower($order);
} else {
$orderd = 'asc';
}
//.........这里部分代码省略.........
开发者ID:forthrobot,项目名称:inuvik,代码行数:101,代码来源:Warehouse.php
示例18: shopp_empty_search_index
/**
* Destroy the entire product search index
*
* @api
* @since 1.3
*
* @return void
**/
function shopp_empty_search_index()
{
$index_table = ShoppDatabaseObject::tablename(ContentIndex::$table);
if (sDB::query("DELETE FROM {$index_table}")) {
return true;
}
return false;
}
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:16,代码来源:core.php
示例19: storage
public function storage()
{
$Shopp = Shopp::object();
$Storage = $Shopp->Storage;
$Storage->settings();
// Load all installed storage engines for settings UIs
if (!empty($_POST['save'])) {
check_admin_referer('shopp-system-storage');
shopp_set_formsettings();
// Re-initialize Storage Engines with new settings
$Storage->settings();
$this->notice(Shopp::__('Shopp system settings saved.'));
} elseif (!empty($_POST['rebuild'])) {
$assets = ShoppDatabaseObject::tablename(ProductImage::$table);
$query = "DELETE FROM {$assets} WHERE context='image' AND type='image'";
if (sDB::query($query)) {
$updated = __('All cached images have been cleared.', 'Shopp');
}
}
// Build the storage options menu
$storage = $engines = $storageset = array();
foreach ($Storage->active as $module) {
$storage[$module->module] = $module->name;
$engines[$module->module] = sanitize_title_with_dashes($module->module);
$storageset[$module->module] = $Storage->get($module->module)->settings;
}
$Storage->ui();
// Setup setting UIs
$ImageStorage = false;
$DownloadStorage = false;
if (isset($_POST['image-settings'])) {
$ImageStorage = $Storage->get(shopp_setting('image_storage'));
}
if (isset($_POST['download-settings'])) {
$DownloadStorage = $Storage->get(shopp_setting('product_storage'));
}
add_action('shopp_storage_engine_settings', array($Storage, 'templates'));
include $this->ui('storage.php');
}
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:39,代码来源:System.php
|
请发表评论