示例#1
0
文件: ui.php 项目: robbiespire/paQui
function tags_meta_box ($Product) {
	$taglist = array();
	foreach ($Product->tags as $tag) $taglist[] = $tag->name;
?>
<input name="newtags" id="newtags" type="text" size="16" tabindex="4" autocomplete="off" value="<?php _e('enter, new, tags','Ecart'); ?>…" title="<?php _e('enter, new, tags','Ecart'); ?>…" class="form-input-tip" />
	<button type="button" name="addtags" id="add-tags" class="button-secondary" tabindex="5"><small><?php _e('Add','Ecart'); ?></small></button><input type="hidden" name="taglist" id="tags" value="<?php echo join(",",esc_attrs($taglist)); ?>" /><br />
<label><?php _e('Separate tags with commas','Ecart'); ?></label>
<div id="taglist">
	<div id="tagchecklist" class="tagchecklist"></div>
</div>
<?php
}
示例#2
0
	/**
	 * Constructs a line item from a Product object and identified price object
	 *	 
	 * @since 1.1
	 *
	 * @param object $Product Product object
	 * @param mixed $pricing A list of price IDs; The option key of a price object; or a Price object
	 * @param int $category (optional)The breadcrumb category ID where the product was added from
	 * @param array $data (optional) Custom data associated with the line item
	 * @param array $addons (optional) A set of addon options
	 * @return void
	 **/
	function __construct ($Product,$pricing,$category=false,$data=array(),$addons=array()) {

		$Product->load_data(array('prices','images','categories','tags','specs'));

		// If product variations are enabled, disregard the first priceline
		if ($Product->variations == "on") array_shift($Product->prices);

		// If option ids are passed, lookup by option key, otherwise by id
		if (is_array($pricing)) {
			$Price = $Product->pricekey[$Product->optionkey($pricing)];
			if (empty($Price)) $Price = $Product->pricekey[$Product->optionkey($pricing,true)];
		} elseif ($pricing !== false) {
			$Price = $Product->priceid[$pricing];
		} else {
			foreach ($Product->prices as &$Price)
				if ($Price->type != "N/A" &&
					(!$Price->stocked ||
					($Price->stocked && $Price->stock > 0))) break;
		}
		if (isset($Product->id)) $this->product = $Product->id;
		if (isset($Price->id)) $this->priceline = $Price->id;

		$this->name = $Product->name;
		$this->slug = $Product->slug;

		$this->category = $category;
		$this->categories = $this->namelist($Product->categories);
		$this->tags = $this->namelist($Product->tags);
		$this->image = current($Product->images);
		$this->description = $Product->summary;

		if ($Product->variations == "on")
			$this->variations($Product->prices);

		if (isset($Product->addons) && $Product->addons == "on")
			$this->addons($this->addonsum,$addons,$Product->prices);

		if (isset($Price->id))
			$this->option = $this->mapprice($Price);

		$this->sku = $Price->sku;
		$this->type = $Price->type;
		$this->sale = $Price->onsale;
		$this->freeshipping = $Price->freeshipping;
		// $this->saved = ($Price->price - $Price->promoprice);
		// $this->savings = ($Price->price > 0)?percentage($this->saved/$Price->price)*100:0;
		$this->unitprice = (($Price->onsale)?$Price->promoprice:$Price->price)+$this->addonsum;
		if ($this->type == "Donation")
			$this->donation = $Price->donation;
		$this->data = stripslashes_deep(esc_attrs($data));

		// Map out the selected menu name and option
		if ($Product->variations == "on") {
			$selected = explode(",",$this->option->options); $s = 0;
			$variants = isset($Product->options['v'])?$Product->options['v']:$Product->options;
			foreach ($variants as $i => $menu) {
				foreach($menu['options'] as $option) {
					if ($option['id'] == $selected[$s]) {
						$this->variation[$menu['name']] = $option['name']; break;
					}
				}
				$s++;
			}
		}

		if (!empty($Price->download)) $this->download = $Price->download;
		if ($Price->type == "Shipped") {
			$this->shipped = true;
			if ($Price->shipping == "on") {
				$this->weight = $Price->weight;
				if (isset($Price->dimensions)) {
					foreach ((array)$Price->dimensions as $dimension => $value)
						$this->$dimension = $value;
				}
				$this->shipfee = $Price->shipfee;
				if (isset($Product->addons) && $Product->addons == "on")
					$this->addons($this->shipfee,$addons,$Product->prices,'shipfee');
			} else $this->freeshipping = true;
		}
		$Settings = EcartSettings();
		$this->inventory = ($Price->inventory == "on")?true:false;
		$this->taxable = ($Price->tax == "on" && $Settings->get('taxes') == "on")?true:false;
	}
示例#3
0
文件: Item.php 项目: borkweb/shopp
 /**
  * Loads or constructs the Item object from product and product pricing parameters
  *
  * @author John Dillick, Jonathan Davis
  * @since 1.2
  *
  * @param object $Product Product object
  * @param mixed $pricing A list of price IDs; The option key of a price object; or a Price object
  * @param int $category (optional)The breadcrumb category ID where the product was added from
  * @param array $data (optional) Custom data associated with the line item
  * @param array $addons (optional) A set of addon options
  * @return void
  **/
 public function load($Product, $pricing, $category = false, $data = array(), $addons = array())
 {
     $Product->load_data();
     // If option ids are passed, lookup by option key, otherwise by id
     $Price = false;
     if (is_array($pricing) && !empty($pricing)) {
         $optionkey = $Product->optionkey($pricing);
         if (!isset($Product->pricekey[$optionkey])) {
             $optionkey = $Product->optionkey($pricing, true);
         }
         // deprecated prime
         if (isset($Product->pricekey[$optionkey])) {
             $Price = $Product->pricekey[$optionkey];
         }
     } elseif (is_numeric($pricing)) {
         $Price = $Product->priceid[$pricing];
     } elseif (is_a($pricing, 'ShoppPrice')) {
         $Price = $pricing;
     }
     // Find single product priceline
     if (!$Price && !Shopp::str_true($Product->variants)) {
         foreach ($Product->prices as &$Price) {
             $stock = true;
             if (Shopp::str_true($Price->inventory) && 1 > $Price->stock) {
                 $stock = false;
             }
             if ('product' == $Price->context && 'N/A' != $Price->type && $stock) {
                 break;
             }
         }
     }
     // Find first available variant priceline
     if (!$Price && Shopp::str_true($Product->variants)) {
         foreach ($Product->prices as &$Price) {
             $stock = true;
             if (Shopp::str_true($Price->inventory) && 1 > $Price->stock) {
                 $stock = false;
             }
             if ('variation' == $Price->context && 'N/A' != $Price->type && $stock) {
                 break;
             }
         }
     }
     if (isset($Product->id)) {
         $this->product = $Product->id;
     }
     if (isset($Price->id)) {
         $this->priceline = $Price->id;
     }
     $this->name = $Product->name;
     $this->slug = $Product->slug;
     $this->category = $category;
     $this->categories = $this->namelist($Product->categories);
     $this->tags = $this->namelist($Product->tags);
     $this->image = current($Product->images);
     $this->description = $Product->summary;
     if (shopp_setting_enabled('taxes')) {
         // Must init taxable above addons roll-up #2825
         $this->taxable = array();
     }
     // Re-init during ShoppCart::change() loads #2922
     // Product has variants
     if (Shopp::str_true($Product->variants) && empty($this->variants)) {
         $this->variants($Product->prices);
     }
     // Product has Addons
     if (Shopp::str_true($Product->addons)) {
         if (!empty($this->addons)) {
             // Compute addon differences
             $addons = array_diff($addons, array_keys($this->addons));
         }
         $this->addons($this->addonsum, $addons, $Product->prices);
     }
     if (isset($Price->id)) {
         $this->option = $this->mapprice($Price);
     }
     $this->sku = $Price->sku;
     $this->type = $Price->type;
     $this->sale = Shopp::str_true($Product->sale);
     $this->freeshipping = isset($Price->freeshipping) ? $Price->freeshipping : false;
     $baseprice = roundprice($this->sale ? $Price->promoprice : $Price->price);
     $this->unitprice = $baseprice + $this->addonsum;
     if (shopp_setting_enabled('taxes')) {
         if (Shopp::str_true($Price->tax)) {
             $this->taxable[] = $baseprice;
         }
         $this->istaxed = array_sum($this->taxable) > 0;
         $this->includetax = shopp_setting_enabled('tax_inclusive');
         if (isset($Product->excludetax) && Shopp::str_true($Product->excludetax)) {
             $this->includetax = false;
         }
     }
     if ('Donation' == $this->type) {
         $this->donation = $Price->donation;
     }
     $this->inventory = Shopp::str_true($Price->inventory) && shopp_setting_enabled('inventory');
     $this->data = stripslashes_deep(esc_attrs($data));
     // Handle Recurrences
     if ($this->has_recurring()) {
         $this->subprice = $this->unitprice;
         $this->recurrences();
         if ($this->is_recurring() && $this->has_trial()) {
             $trial = $this->trial();
             $this->unitprice = $trial['price'];
         }
     }
     // Map out the selected menu name and option
     if (Shopp::str_true($Product->variants)) {
         $selected = explode(',', $this->option->options);
         $s = 0;
         $variants = isset($Product->options['v']) ? $Product->options['v'] : $Product->options;
         foreach ((array) $variants as $i => $menu) {
             foreach ((array) $menu['options'] as $option) {
                 if ($option['id'] == $selected[$s]) {
                     $this->variant[$menu['name']] = $option['name'];
                     break;
                 }
             }
             $s++;
         }
     }
     $this->packaging = Shopp::str_true(shopp_product_meta($Product->id, 'packaging'));
     if (!empty($Price->download)) {
         $this->download = $Price->download;
     }
     $this->shipped = 'Shipped' == $Price->type;
     if ($this->shipped) {
         $dimensions = array('weight' => 0, 'length' => 0, 'width' => 0, 'height' => 0);
         if (Shopp::str_true($Price->shipping)) {
             $this->shipfee = $Price->shipfee;
             if (isset($Price->dimensions)) {
                 $dimensions = array_merge($dimensions, $Price->dimensions);
             }
         } else {
             $this->freeshipping = true;
         }
         if (isset($Product->addons) && Shopp::str_true($Product->addons)) {
             $this->addons($dimensions, $addons, $Product->prices, 'dimensions');
             $this->addons($this->shipfee, $addons, $Product->prices, 'shipfee');
         }
         foreach ($dimensions as $dimension => $value) {
             $this->{$dimension} = $value;
         }
         if (isset($Product->processing) && Shopp::str_true($Product->processing)) {
             if (isset($Product->minprocess)) {
                 $this->processing['min'] = $Product->minprocess;
             }
             if (isset($Product->maxprocess)) {
                 $this->processing['max'] = $Product->maxprocess;
             }
         }
     }
 }