Esempio n. 1
0
function settings_meta_box($Customer)
{
    ?>
	<p>
		<span>
		<input type="hidden" name="marketing" value="no" />
		<input type="checkbox" id="marketing" name="marketing" value="yes"<?php 
    echo $Customer->marketing == 'yes' ? ' checked="checked"' : '';
    ?>
/>
		<label for="marketing" class="inline">&nbsp;<?php 
    _e('Subscribes to marketing', 'Shopp');
    ?>
</label>
		</span>
	</p>
	<br class="clear" />
	<p>
		<span>
		<select name="type"><?php 
    echo Shopp::menuoptions(Lookup::customer_types(), $Customer->type);
    ?>
</select>
		<label for="type"><?php 
    _e('Customer Type', 'Shopp');
    ?>
</label>
		</span>
	</p>
	<br class="clear" />
	<?php 
    do_action('shopp_customer_editor_settings', $Customer);
}
Esempio n. 2
0
 public function suggestions()
 {
     check_admin_referer('wp_ajax_shopp_suggestions');
     if (isset($_GET['t'])) {
         // @legacy
         switch ($_GET['t']) {
             case "product-name":
                 $_GET['s'] = 'shopp_products';
                 break;
             case "product-tags":
                 $_GET['s'] = 'shopp_tag';
                 break;
             case "product-category":
                 $_GET['s'] = 'shopp_category';
                 break;
             case "customer-type":
                 $_GET['s'] = 'shopp_customer_types';
                 break;
         }
     }
     if (isset($_GET['s'])) {
         global $wpdb;
         $source = strtolower($_GET['s']);
         $q = $_GET['q'];
         $orderlimit = '';
         do_action('shopp_suggestions_from_' . $source);
         $joins = $where = array();
         switch ($source) {
             case 'wp_posts':
                 $id = 'ID';
                 $name = 'post_title';
                 $table = $wpdb->posts;
                 $where[] = "post_type='post'";
                 break;
             case 'wp_pages':
                 $id = 'ID';
                 $name = 'post_title';
                 $table = $wpdb->posts;
                 $where[] = "post_type='page'";
                 break;
             case 'wp_categories':
                 $id = 't.term_id';
                 $name = 'name';
                 $table = "{$wpdb->terms} AS t";
                 $joins[] = "INNER JOIN  {$wpdb->term_taxonomy} AS tt ON tt.term_id = t.term_id";
                 $where[] = "tt.taxonomy = 'category'";
                 break;
             case 'wp_tags':
                 $id = 't.term_id';
                 $name = 'name';
                 $table = "{$wpdb->terms} AS t";
                 $joins[] = "INNER JOIN  {$wpdb->term_taxonomy} AS tt ON tt.term_id = t.term_id";
                 $where[] = "tt.taxonomy = 'post_tag'";
                 break;
             case 'wp_media':
                 $id = 'ID';
                 $name = 'post_title';
                 $table = $wpdb->posts;
                 $where[] = "post_type='attachment'";
                 break;
             case 'wp_users':
                 $id = 'ID';
                 $name = 'user_login';
                 $table = $wpdb->users;
                 break;
             case 'shopp_memberships':
                 $id = 'id';
                 $name = 'name';
                 $table = ShoppDatabaseObject::tablename('meta');
                 $where[] = "context='membership'";
                 $where[] = "type='membership'";
                 break;
             case 'shopp_products':
                 $id = 'ID';
                 $name = 'post_title';
                 $table = $wpdb->posts;
                 $where[] = "post_type='" . ShoppProduct::$posttype . "'";
                 break;
             case 'shopp_promotions':
                 $id = 'id';
                 $name = 'name';
                 $table = ShoppDatabaseObject::tablename(ShoppPromo::$table);
                 break;
             case 'shopp_downloads':
                 $id = 'id';
                 $name = 'name';
                 $table = ShoppDatabaseObject::tablename('meta');
                 $where[] = "context='price'";
                 $where[] = "type='download'";
                 break;
             case 'shopp_target_markets':
                 $markets = shopp_setting('target_markets');
                 $results = array();
                 foreach ($markets as $id => $market) {
                     if (strpos(strtolower($market), strtolower($_GET['q'])) !== false) {
                         $_ = new StdClass();
                         $_->id = $id;
                         $_->name = stripslashes($market);
                         $results[] = $_;
                     }
                 }
                 echo json_encode($results);
                 exit;
                 break;
             case 'shopp_customer_types':
                 $types = Lookup::customer_types();
                 $results = array();
                 foreach ($types as $id => $type) {
                     if (strpos(strtolower($type), strtolower($_GET['q'])) !== false) {
                         $_ = new StdClass();
                         $_->id = $id;
                         $_->name = $type;
                         $results[] = $_;
                     }
                 }
                 echo json_encode($results);
                 exit;
                 break;
             default:
                 if (taxonomy_exists($_GET['s'])) {
                     $taxonomy = $_GET['s'];
                     $id = 't.term_id';
                     $name = 'name';
                     $table = "{$wpdb->terms} AS t";
                     $joins[] = "INNER JOIN  {$wpdb->term_taxonomy} AS tt ON tt.term_id = t.term_id";
                     $where[] = "tt.taxonomy = '" . $taxonomy . "'";
                     if ('shopp_popular_tags' == strtolower($q)) {
                         $q = '';
                         $orderlimit = "ORDER BY tt.count DESC LIMIT 15";
                     }
                 }
                 break;
         }
         if (!empty($q)) {
             $where[] = "{$name} LIKE '%" . sDB::escape($q) . "%'";
         }
         $where = join(' AND ', $where);
         $joins = join(' ', $joins);
         $query = "SELECT {$id} AS id, {$name} AS name FROM {$table} {$joins} WHERE {$where} {$orderlimit}";
         $items = sDB::query($query, 'array');
         echo json_encode($items);
         exit;
     }
 }
Esempio n. 3
0
<p class="clearfix">
	<span>
	<input type="hidden" name="marketing" value="no" />
	<input type="checkbox" id="marketing" name="marketing" value="yes"<?php 
echo $Customer->marketing == 'yes' ? ' checked="checked"' : '';
?>
/>
	<label for="marketing" class="inline">&nbsp;<?php 
_e('Subscribes to marketing', 'Shopp');
?>
</label>
	</span>
</p>
<p class="clearfix">
	<span>
	<label for="customer-type"><?php 
_e('Customer Type', 'Shopp');
?>
</label>
	<select id="customer-type" name="type"><?php 
echo Shopp::menuoptions(Lookup::customer_types(), $Customer->type);
?>
</select>
	</span>
</p>
Esempio n. 4
0
	function suggestions () {
		check_admin_referer('wp_ajax_ecart_suggestions');
		$db = DB::get();

		switch($_GET['t']) {
			case "product-name": $table = DatabaseObject::tablename(Product::$table); break;
			case "product-tags": $table = DatabaseObject::tablename(Tag::$table); break;
			case "product-category": $table = DatabaseObject::tablename(Category::$table); break;
			case "customer-type":
				$types = Lookup::customer_types();
				$results = array();
				foreach ($types as $type)
					if (strpos(strtolower($type),strtolower($_GET['q'])) !== false) $results[] = $type;
				echo join("\n",$results);
				exit();
				break;
		}

		$entries = $db->query("SELECT name FROM $table WHERE name LIKE '%{$_GET['q']}%'",AS_ARRAY);
		$results = array();
		foreach ($entries as $entry) $results[] = $entry->name;
		echo join("\n",$results);
		exit();
	}