Exemplo n.º 1
0
 public function view()
 {
     if ($this->hasNotEmpty('slug')) {
         return $this->item();
     }
     Ajde::app()->getDocument()->setTitle('Shop');
     $products = new ProductCollection();
     $products->orderBy('sort', Ajde_Query::ORDER_ASC);
     $this->getView()->assign('products', $products);
     return $this->render();
 }
Exemplo n.º 2
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
require_once 'include/header.php';
$productCollection = new ProductCollection();
$products = $productCollection->all();
?>

<div class="container">
    <a href="product_add.php" class="btn btn-default">Add Product</a>
    <br><br>
    <table class="table table-striped">
        <tr>
            <th>Product</th>
            <th>Price</th>
            <th>Quantity</th>
            <th>Date Added</th>
            <th>Action?</th>
        </tr>

        <?php 
foreach ($products as $product) {
    ?>
            <tr>
                <td><?php 
    echo $product->getName();
    ?>
</td>
                <td><?php 
    echo $product->getPrice();
    ?>
Exemplo n.º 3
0
    /**
     * 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;
    }
Exemplo n.º 4
0
 public function load(array $options = array())
 {
     $this->loading = $options = array_merge($this->_options, $options);
     if (isset($this->loading['show'])) {
         $this->loading['limit'] = $this->loading['show'];
         unset($this->loading['show']);
     }
     if (isset($options['pagination'])) {
         $this->loading['pagination'] = $options['pagination'];
     }
     if (isset($options['exclude'])) {
         $exclude = $options['exclude'];
         if (is_numeric(str_replace(',', '', $exclude))) {
             global $wpdb;
             $this->loading['joins'][] = "INNER JOIN {$wpdb->term_relationships} as tr ON p.ID = tr.object_id";
             $this->loading['joins'][] = "INNER JOIN {$wpdb->term_taxonomy} as tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
             $this->loading['where'][] = "tr.term_taxonomy_id NOT IN ({$exclude})";
             $this->loading['where'][] = "tt.taxonomy = 'shopp_category'";
         }
     }
     $this->smart($this->loading);
     parent::load($this->loading);
 }
Exemplo n.º 5
0
<?php

include dirname(__FILE__) . '/core/partials/pageCheck.php';
include_once Config::$root_path . '/classes/productCollection.php';
$thisPage = "collection";
$id = Utility::getRequestVariable('id', 0);
$errorMsg = "";
if ($id == 0) {
    $errorMsg = "You must specify a valid collection id.";
} else {
    try {
        $class = new ProductCollection($userID, $tenantID);
        $collection = $class->getEntity($id);
        $title = $collection["name"];
        Log::logPageView('collection', $id, '');
    } catch (Exception $ex) {
        $errorMsg = "Unable to load requested collection: " . $ex->getMessage();
        $title = "Not Found";
    }
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title><?php 
echo Utility::getTenantProperty($applicationID, $_SESSION['tenantID'], $userID, 'title') . ': ' . $title;
?>
</title>
        <?php 
Exemplo n.º 6
0
 public function upgrade_130()
 {
     global $wpdb;
     $db_version = ShoppSettings::dbversion();
     if ($db_version < 1201) {
         // 1.3 schema changes
         $this->upschema();
         // All existing sessions must be cleared and restarted, 1.3 & 1.3.6 sessions are not compatible with any prior version of Shopp
         ShoppShopping()->reset();
         $sessions_table = ShoppDatabaseObject::tablename('shopping');
         sDB::query("DELETE FROM {$sessions_table}");
         // Remove all the temporary PHP native session data from the options table
         sDB::query("DELETE FROM from {$wpdb->options} WHERE option_name LIKE '__php_session_*'");
     }
     if ($db_version < 1200) {
         $meta_table = ShoppDatabaseObject::tablename('meta');
         sDB::query("UPDATE {$meta_table} SET value='on' WHERE name='theme_templates' AND (value != '' AND value != 'off')");
         sDB::query("DELETE FROM {$meta_table} WHERE type='image' AND value LIKE '%O:10:\"ShoppError\"%'");
         // clean up garbage from legacy bug
         sDB::query("DELETE FROM {$meta_table} WHERE CONCAT('', name *1) = name AND context = 'category' AND type = 'meta'");
         // clean up bad category meta
         // Update purchase gateway values to match new prefixed class names
         $gateways = array('PayPalStandard' => 'ShoppPayPalStandard', '_2Checkout' => 'Shopp2Checkout', 'OfflinePayment' => 'ShoppOfflinePayment', 'TestMode' => 'ShoppTestMode', 'FreeOrder' => 'ShoppFreeOrder');
         foreach ($gateways as $name => $classname) {
             sDB::query("UPDATE {$purchase_table} SET gateway='{$classname}' WHERE gateway='{$name}'");
         }
         $activegateways = explode(',', shopp_setting('active_gateways'));
         foreach ($activegateways as &$setting) {
             if (false === strpos($setting, 'Shopp')) {
                 $setting = str_replace(array_keys($gateways), $gateways, $setting);
             }
         }
         shopp_set_setting('active_gateways', join(',', $activegateways));
     }
     if ($db_version < 1200 && shopp_setting_enabled('tax_inclusive')) {
         $price_table = ShoppDatabaseObject::tablename('price');
         $taxrates = shopp_setting('taxrates');
         $baseop = shopp_setting('base_operations');
         $taxtaxes = array();
         // Capture taxonomy condition tax rates
         $basetaxes = array();
         // Capture base of operations rate(s)
         foreach ($taxrates as $rate) {
             if (!($baseop['country'] == $rate['country'] || ShoppTax::ALL == $rate['country'])) {
                 continue;
             }
             if (!empty($rate['zone']) && $baseop['zone'] != $rate['zone']) {
                 continue;
             }
             if (!empty($rate['rules']) && $rate['logic'] == 'any') {
                 // Capture taxonomy conditional rates
                 foreach ($rate['rules'] as $raterule) {
                     if ('product-category' == $raterule['p']) {
                         $taxname = ProductCategory::$taxon . '::' . $raterule['v'];
                     } elseif ('product-tags' == $raterule['p']) {
                         $taxname = ProductTag::$taxon . '::' . $raterule['v'];
                     }
                     $taxtaxes[$taxname] = Shopp::floatval($rate['rate']) / 100;
                 }
             } else {
                 $basetaxes[] = Shopp::floatval($rate['rate']) / 100;
             }
         }
         // Find products by in each taxonomy termno
         $done = array();
         // Capture each set into the "done" list
         foreach ($taxtaxes as $taxterm => $taxrate) {
             list($taxonomy, $name) = explode('::', $taxterm);
             $Collection = new ProductCollection();
             $Collection->load(array('ids' => true, 'taxquery' => array(array('taxonomy' => $taxonomy, 'field' => 'name', 'terms' => $name))));
             $query = "UPDATE {$price_table} SET price=price+(price*{$taxrate}) WHERE tax='on' AND product IN (" . join(',', $Collection->products) . ")";
             sDB::query($query);
             $done = array_merge($done, $Collection->products);
         }
         // Update the rest of the prices (skipping those we've already done) with the tax rate that matches the base of operations
         $taxrate = array_sum($basetaxes);
         // Merge all the base taxes into a single rate
         $done = empty($done) ? '' : " AND product NOT IN (" . join(',', $done) . ")";
         $query = "UPDATE {$price_table} SET price=price+(price*{$taxrate}) WHERE tax='on'{$done}";
         sDB::query($query);
     }
 }
 /**
  * @test
  * @covers WalmartApiClient\Entity\Collection\AbstractCollection::toArray
  */
 public function testToArray()
 {
     $product1 = new \WalmartApiClient\Entity\Product(['itemId' => 1]);
     $product2 = new \WalmartApiClient\Entity\Product(['itemId' => 2]);
     $collection = new ProductCollection([$product1, $product2]);
     $array = $collection->toArray();
     $this->assertTrue($array[0]['itemId'] === 1);
     $this->assertTrue($array[1]['itemId'] === 2);
 }
Exemplo n.º 8
0
    ?>
" />
                    <input id="coreServiceUrl" type="hidden" value="<?php 
    echo Config::getCoreServiceRoot();
    ?>
" />
                    <div id="mapwrapper" class="mapWrapper">
                        <div id="mapcanvas"></div>
                        <div id="loading" class="modal"><!-- Place inside div to cover --></div>
                    </div>
                </div>
                <?php 
}
$productListId = $propertyBag->getProperty($bagName, 'productListId', 0);
if ($productListId > 0) {
    $class = new ProductCollection($userID, $tenantID);
    $collection = $class->getEntity($productListId);
    ?>
                        <div class="container featureContainer condensed">
                            <h3><?php 
    echo Utility::renderContent('region:productListTitle' . $region, $_SESSION['tenantID'], $user);
    ?>
</h3>
                            <p><?php 
    echo Utility::renderContent('region:productListDescription' . $region, $_SESSION['tenantID'], $user);
    ?>
</p>
                            <input id="queryParams" type="hidden" value="<?php 
    echo $collection["queryParams"];
    ?>
" />
Exemplo n.º 9
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
require_once 'include/header.php';
if (isset($_GET['id']) && isset($_GET['confirm'])) {
    $productCollection = new ProductCollection();
    $productCollection->remove(array('id' => $_GET['id']));
    header('Location: product_list.php');
}
?>

<div class="container">
    <h1>Are you sure you want to delete this product?</h1>

    <a href="product_delete.php?id=<?php 
echo $_GET['id'];
?>
&confirm=1" class="btn btn-danger">Yes</a>
    <a href="product_list.php" class="btn btn-default">No</a>
</div>

<?php 
require_once 'include/footer.php';
Exemplo n.º 10
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entity = new Product();
    $entity->setId($_GET['id'])->setUserId($_POST['user_id'])->setName($_POST['name'])->setPrice($_POST['price'])->setQuantity($_POST['quantity'])->setDateAdded(date('Y-m-d H:i:s'))->saveImage($_FILES['image']);
    $productCollection = new ProductCollection();
    $productCollection->save($entity);
    header('Location: product_list.php');
    exit;
}
$productCollection = new ProductCollection();
$product = $productCollection->one(array('id' => $_GET['id']));
$userCollection = new UserCollection();
$users = $userCollection->all();
require_once 'include/header.php';
?>

    <div class="container">
        <a href="product_image_list.php?product_id=<?php 
echo $product->getId();
?>
" class="btn btn-success">Gallery</a>
        <br><br>

        <form method="post" action="" enctype="multipart/form-data">
            <div class="form-group">
                <label for="user">User:</label>
                <select name="user_id" id="user" class="form-control">
                    <?php 
foreach ($users as $user) {