当前位置: 首页>>代码示例>>PHP>>正文


PHP Price::save方法代码示例

本文整理汇总了PHP中Price::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Price::save方法的具体用法?PHP Price::save怎么用?PHP Price::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Price的用法示例。


在下文中一共展示了Price::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Price();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Price'])) {
         $model->attributes = $_POST['Price'];
         if ($model->save()) {
             $msg = 'Позиция прайса #' . $model->id . ' - ' . $model->name . ' создана';
             Yii::app()->user->setFlash('success', $msg);
             Yii::app()->logger->write($msg);
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ASDAFF,项目名称:its-crm,代码行数:20,代码来源:PriceController.php

示例2: actionAddInfo

 public function actionAddInfo()
 {
     $routeId = intval($_POST['route_id']) ? intval($_POST['route_id']) : '';
     if (!$routeId) {
         exit;
     }
     $a = 1000000000;
     if ($_POST['basic_neicang1'] != NULL && $a > (int) $_POST['basic_neicang1']) {
         $a = (int) $_POST['basic_neicang1'];
     }
     if ($_POST['classic_neicang1'] != NULL && $a > (int) $_POST['classic_neicang1']) {
         $a = (int) $_POST['classic_neicang1'];
     }
     if ($_POST['basic_haijing1'] != NULL && $a > (int) $_POST['basic_haijing1']) {
         $a = (int) $_POST['basic_haijing1'];
     }
     if ($_POST['classic_haijing1'] != NULL && $a > (int) $_POST['basic_haijing1']) {
         $a = (int) $_POST['classic_haijing1'];
     }
     if ($_POST['basic_yangtai1'] != NULL && $a > (int) $_POST['basic_yangtai1']) {
         $a = (int) $_POST['basic_yangtai1'];
     }
     if ($_POST['classic_yangtai1'] != NULL && $a > (int) $_POST['classic_yangtai1']) {
         $a = (int) $_POST['classic_yangtai1'];
     }
     if ($_POST['basic_taofang1'] != NULL && $a > (int) $_POST['basic_taofang1']) {
         $a = (int) $_POST['basic_taofang1'];
     }
     if ($_POST['classic_taofang1'] != NULL && $a > (int) $_POST['classic_taofang1']) {
         $a = (int) $_POST['classic_taofang1'];
     }
     $a1 = $_POST['basic_neicang1'] . ',' . $_POST['basic_neicang2'] . ',' . $_POST['basic_neicang3'];
     $a2 = $_POST['classic_neicang1'] . ',' . $_POST['classic_neicang2'] . ',' . $_POST['classic_neicang3'];
     $b1 = $_POST['basic_haijing1'] . ',' . $_POST['basic_haijing2'] . ',' . $_POST['basic_haijing3'];
     $b2 = $_POST['classic_haijing1'] . ',' . $_POST['classic_haijing2'] . ',' . $_POST['classic_haijing3'];
     $c1 = $_POST['basic_yangtai1'] . ',' . $_POST['basic_yangtai2'] . ',' . $_POST['basic_yangtai3'];
     $c2 = $_POST['classic_yangtai1'] . ',' . $_POST['classic_yangtai2'] . ',' . $_POST['classic_yangtai3'];
     $d1 = $_POST['basic_taofang1'] . ',' . $_POST['basic_taofang2'] . ',' . $_POST['basic_taofang3'];
     $d2 = $_POST['classic_taofang1'] . ',' . $_POST['classic_taofang2'] . ',' . $_POST['classic_taofang3'];
     $price = new Price();
     $price->basic_neicang = $a1;
     $price->classic_neicang = $a2;
     $price->basic_haijing = $b1;
     $price->classic_haijing = $b2;
     $price->basic_yangtai = $c1;
     $price->classic_yangtai = $c2;
     $price->basic_taofang = $d1;
     $price->classic_taofang = $d2;
     $price->route_id = $routeId;
     $ret = $price->save();
     if ($ret > 0) {
         Route::model()->updateByPk($routeId, array('price_id' => $price->id));
     }
     if ($a != 1000000000) {
         Route::model()->updateByPk($routeId, array('price' => $a));
     }
     $this->redirect(Yii::app()->request->urlReferrer);
 }
开发者ID:rocketyang,项目名称:yii2,代码行数:58,代码来源:PriceController.php

示例3: array

 function save_product($Product)
 {
     global $Shopp;
     $db = DB::get();
     check_admin_referer('shopp-save-product');
     if (!current_user_can(SHOPP_USERLEVEL)) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $this->settings_save();
     // Save workflow setting
     $base = $Shopp->Settings->get('base_operations');
     $taxrate = 0;
     if ($base['vat']) {
         $taxrate = $Shopp->Cart->taxrate();
     }
     if (!$_POST['options']) {
         $Product->options = array();
     } else {
         $_POST['options'] = stripslashes_deep($_POST['options']);
     }
     if (empty($Product->slug)) {
         $Product->slug = sanitize_title_with_dashes($_POST['name']);
     }
     // Check for an existing product slug
     $exclude_product = !empty($Product->id) ? "AND id != {$Product->id}" : "";
     $existing = $db->query("SELECT slug FROM {$Product->_table} WHERE slug='{$Product->slug}' {$exclude_product} LIMIT 1");
     if ($existing) {
         $suffix = 2;
         while ($existing) {
             $altslug = substr($Product->slug, 0, 200 - (strlen($suffix) + 1)) . "-{$suffix}";
             $existing = $db->query("SELECT slug FROM {$Product->_table} WHERE slug='{$altslug}' {$exclude_product} LIMIT 1");
             $suffix++;
         }
         $Product->slug = $altslug;
     }
     if (isset($_POST['content'])) {
         $_POST['description'] = $_POST['content'];
     }
     $Product->updates($_POST, array('categories'));
     $Product->save();
     $Product->save_categories($_POST['categories']);
     $Product->save_tags(explode(",", $_POST['taglist']));
     if (!empty($_POST['price']) && is_array($_POST['price'])) {
         // Delete prices that were marked for removal
         if (!empty($_POST['deletePrices'])) {
             $deletes = array();
             if (strpos($_POST['deletePrices'], ",")) {
                 $deletes = explode(',', $_POST['deletePrices']);
             } else {
                 $deletes = array($_POST['deletePrices']);
             }
             foreach ($deletes as $option) {
                 $Price = new Price($option);
                 $Price->delete();
             }
         }
         // Save prices that there are updates for
         foreach ($_POST['price'] as $i => $option) {
             if (empty($option['id'])) {
                 $Price = new Price();
                 $option['product'] = $Product->id;
             } else {
                 $Price = new Price($option['id']);
             }
             $option['sortorder'] = array_search($i, $_POST['sortorder']) + 1;
             // Remove VAT amount to save in DB
             if ($base['vat'] && $option['tax'] == "on") {
                 $option['price'] = number_format(floatnum($option['price']) / (1 + $taxrate), 2);
                 $option['saleprice'] = number_format(floatnum($option['saleprice']) / (1 + $taxrate), 2);
             }
             $Price->updates($option);
             $Price->save();
             if (!empty($option['download'])) {
                 $Price->attach_download($option['download']);
             }
             if (!empty($option['downloadpath'])) {
                 $basepath = trailingslashit($Shopp->Settings->get('products_path'));
                 $download = $basepath . ltrim($option['downloadpath'], "/");
                 if (file_exists($download)) {
                     $File = new Asset();
                     $File->parent = 0;
                     $File->context = "price";
                     $File->datatype = "download";
                     $File->name = basename($download);
                     $File->value = substr(dirname($download), strlen($basepath));
                     $File->size = filesize($download);
                     $File->properties = array("mimetype" => file_mimetype($download, $File->name));
                     $File->save();
                     $Price->attach_download($File->id);
                 }
             }
         }
         unset($Price);
     }
     // No variation options at all, delete all variation-pricelines
     if (empty($Product->options) && !empty($Product->prices) && is_array($Product->prices)) {
         foreach ($Product->prices as $priceline) {
             // Skip if not tied to variation options
             if ($priceline->optionkey == 0) {
                 continue;
//.........这里部分代码省略.........
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:101,代码来源:Flow.php

示例4: duplicate

	function duplicate () {
		$db =& DB::get();

		$this->load_data(array('prices','specs','categories','tags','images','taxes'=>'false'));
		$this->id = '';
		$this->name = $this->name.' '.__('copy','Ecart');
		$this->slug = sanitize_title_with_dashes($this->name);

		// Check for an existing product slug
		$existing = $db->query("SELECT slug FROM $this->_table WHERE slug='$this->slug' LIMIT 1");
		if ($existing) {
			$suffix = 2;
			while($existing) {
				$altslug = substr($this->slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
				$existing = $db->query("SELECT slug FROM $this->_table WHERE slug='$altslug' LIMIT 1");
				$suffix++;
			}
			$this->slug = $altslug;
		}
		$this->created = '';
		$this->modified = '';

		$this->save();

		// Copy prices
		foreach ($this->prices as $price) {
			$Price = new Price();
			$Price->updates($price,array('id','product','created','modified'));
			$Price->product = $this->id;
			$Price->save();
		}

		// Copy sepcs
		foreach ($this->specs as $spec) {
			$Spec = new Spec();
			$Spec->updates($spec,array('id','parent','created','modified'));
			$Spec->parent = $this->id;
			$Spec->save();
		}

		// Copy categories
		$categories = array();
		foreach ($this->categories as $category) $categories[] = $category->id;
		$this->categories = array();
		$this->save_categories($categories);

		// Copy tags
		$taglist = array();
		foreach ($this->tags as $tag) $taglist[] = $tag->name;
		$this->tags = array();
		$this->save_tags($taglist);

		// Copy product images
		foreach ($this->images as $ProductImage) {
			$Image = new ProductImage();
			$Image->updates($ProductImage,array('id','parent','created','modified'));
			$Image->parent = $this->id;
			$Image->save();
		}

	}
开发者ID:robbiespire,项目名称:paQui,代码行数:61,代码来源:Product.php

示例5: substr

	/**
	 * Handles saving updates from the product editor
	 *
	 * Saves all product related information which includes core product data
	 * and supporting elements such as images, digital downloads, tags,
	 * assigned categories, specs and pricing variations.
	 *	 
	 * @return void
	 **/
	function save_product ($Product) {
		$db = DB::get();
		$Settings = &EcartSettings();
		check_admin_referer('ecart-save-product');

		if ( !(is_ecart_userlevel() || current_user_can('ecart_products')) )
			wp_die(__('You do not have sufficient permissions to access this page.'));

		$Settings->saveform(); // Save workflow setting

		$base = $Settings->get('base_operations');
		$taxrate = 0;
		if ($base['vat']) $taxrate = ecart_taxrate(null,true,$Product);

		if (empty($_POST['options'])) $Product->options = array();
		else $_POST['options'] = stripslashes_deep($_POST['options']);

		if (empty($Product->slug)) $Product->slug = sanitize_title_with_dashes($_POST['name']);

		// Check for an existing product slug
		$exclude_product = !empty($Product->id)?"AND id != $Product->id":"";
		$existing = $db->query("SELECT slug FROM $Product->_table WHERE slug='$Product->slug' $exclude_product LIMIT 1");
		if ($existing) {
			$suffix = 2;
			while($existing) {
				$altslug = substr($Product->slug, 0, 200-(strlen($suffix)+1)). "-".$suffix++;
				$existing = $db->query("SELECT slug FROM $Product->_table WHERE slug='$altslug' $exclude_product LIMIT 1");
			}
			$Product->slug = $altslug;
		}

		if ($_POST['status'] == "publish") {
			$publishfields = array('month' => '','date' => '','year' => '','hour'=>'','minute'=>'','meridiem'=>'');
			$publishdate = join('',array_merge($publishfields,$_POST['publish']));
			if (!empty($publishdate)) {
				if ($_POST['publish']['meridiem'] == "PM" && $_POST['publish']['hour'] < 12)
					$_POST['publish']['hour'] += 12;
				$_POST['publish'] = mktime($_POST['publish']['hour'],$_POST['publish']['minute'],0,$_POST['publish']['month'],$_POST['publish']['date'],$_POST['publish']['year']);
			} else {
				unset($_POST['publish']);
				// Auto set the publish date if not set (or more accurately, if set to an irrelevant timestamp)
				if ($Product->publish <= 86400) $Product->publish = time();
			}
		} else {
			unset($_POST['publish']);
			$Product->publish = 0;
		}

		if (isset($_POST['content'])) $_POST['description'] = $_POST['content'];

		$Product->updates($_POST,array('categories','prices'));
		$Product->save();

		$Product->save_categories($_POST['categories']);
		$Product->save_tags(explode(",",$_POST['taglist']));

		if (!empty($_POST['price']) && is_array($_POST['price'])) {

			// Delete prices that were marked for removal
			if (!empty($_POST['deletePrices'])) {
				$deletes = array();
				if (strpos($_POST['deletePrices'],","))	$deletes = explode(',',$_POST['deletePrices']);
				else $deletes = array($_POST['deletePrices']);

				foreach($deletes as $option) {
					$Price = new Price($option);
					$Price->delete();
				}
			}

			// Save prices that there are updates for
			foreach($_POST['price'] as $i => $option) {
				if (empty($option['id'])) {
					$Price = new Price();
					$option['product'] = $Product->id;
				} else $Price = new Price($option['id']);
				$option['sortorder'] = array_search($i,$_POST['sortorder'])+1;

				// Remove VAT amount to save in DB
				if ($base['vat'] && isset($option['tax']) && $option['tax'] == "on") {
					$option['price'] = (floatvalue($option['price'])/(1+$taxrate));
					$option['saleprice'] = (floatvalue($option['saleprice'])/(1+$taxrate));
				}
				$option['shipfee'] = floatvalue($option['shipfee']);

				$option['weight'] = floatvalue($option['weight']);
				if (isset($options['dimensions']) && is_array($options['dimensions']))
					foreach ($option['dimensions'] as &$dimension)
						$dimension = floatvalue($dimension);

				$Price->updates($option);
//.........这里部分代码省略.........
开发者ID:robbiespire,项目名称:paQui,代码行数:101,代码来源:Warehouse.php

示例6: elseif

} elseif ($request->GetVar('theyear', 'get') !== $request->undefined) {
    $theyear = $request->GetVar('theyear', 'get');
} else {
    $todaydate = getdate();
    $theyear = $todaydate['year'];
}
if ($request->GetVar('frm_theseason', 'post') !== $request->undefined) {
    $theseason = $request->GetVar('frm_theseason', 'post');
} elseif ($request->GetVar('theseason', 'get') !== $request->undefined) {
    $theseason = $request->GetVar('theseason', 'get');
} else {
    $theseason = -1;
}
$smarty->assign('tpl_theseason', $theseason);
if ($request->GetVar('frm_action', 'post') == 'save') {
    $price->save();
}
$prices = $price->getall('N');
$prices2 = $price->getall('A');
if ($request->GetVar('frm_copy', 'post') !== $request->undefined) {
    $cpyfrom = $request->GetVar('frm_copy', 'post');
    $cpyto = substr($theseason, 1, strlen($theseason));
    $prices[$cpyto] = $prices[$cpyfrom];
    $prices2[$cpyto] = $prices2[$cpyfrom];
    $setaltered = true;
} else {
    $setaltered = false;
}
$smarty->assign('tpl_altered', $setaltered);
$smarty->assign('tpl_prices', $prices);
$smarty->assign('tpl_prices2', $prices2);
开发者ID:BackupTheBerlios,项目名称:zvs,代码行数:31,代码来源:price.php

示例7: duplicate

 function duplicate()
 {
     $db =& DB::get();
     $this->load_data(array('prices', 'specs', 'categories', 'tags', 'images', 'taxes' => 'false'));
     $this->id = '';
     $this->name = $this->name . ' ' . __('copy', 'Shopp');
     $this->slug = sanitize_title_with_dashes($this->name);
     // Check for an existing product slug
     $existing = $db->query("SELECT slug FROM {$this->_table} WHERE slug='{$this->slug}' LIMIT 1");
     if ($existing) {
         $suffix = 2;
         while ($existing) {
             $altslug = substr($this->slug, 0, 200 - (strlen($suffix) + 1)) . "-{$suffix}";
             $existing = $db->query("SELECT slug FROM {$this->_table} WHERE slug='{$altslug}' LIMIT 1");
             $suffix++;
         }
         $this->slug = $altslug;
     }
     $this->created = '';
     $this->modified = '';
     $this->save();
     // Copy prices
     foreach ($this->prices as $price) {
         $Price = new Price();
         $Price->updates($price, array('id', 'product', 'created', 'modified'));
         $Price->product = $this->id;
         $Price->save();
     }
     // Copy sepcs
     foreach ($this->specs as $spec) {
         $Spec = new Spec();
         $Spec->updates($spec, array('id', 'product', 'created', 'modified'));
         $Spec->product = $this->id;
         $Spec->save();
     }
     // Copy categories
     $categories = array();
     foreach ($this->categories as $category) {
         $categories[] = $category->id;
     }
     $this->categories = array();
     $this->save_categories($categories);
     // Copy tags
     $taglist = array();
     foreach ($this->tags as $tag) {
         $taglist[] = $tag->name;
     }
     $this->tags = array();
     $this->save_tags($taglist);
     // // Copy product images
     $template = new Asset();
     $columns = array();
     $values = array();
     foreach ($template->_datatypes as $name => $type) {
         $colname = $name;
         $columns[$colname] = $name;
         if ($name == "id") {
             $name = "''";
         }
         if ($name == "parent") {
             $name = "'{$this->id}'";
         }
         if ($name == "created" || $name == "modified") {
             $name = "now()";
         }
         $values[$colname] = $name;
     }
     $sets = array('image', 'small', 'thumbnail');
     $images = array();
     foreach ($sets as $set) {
         foreach ($this->imagesets[$set] as $image) {
             if (isset($images[$image->src])) {
                 $values['src'] = $images[$image->src];
             }
             $id = $db->query("INSERT {$template->_table} (" . join(',', $columns) . ") SELECT " . join(",", $values) . " FROM {$template->_table} WHERE id={$image->id}");
             if ($set == "image") {
                 $images[$image->id] = $id;
                 $db->query("UPDATE {$template->_table} SET src={$id} WHERE id={$id} LIMIT 1");
             }
         }
     }
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:82,代码来源:Product.php

示例8: Price

	function update_inventory () {
		check_admin_referer('wp_ajax_ecart_update_inventory');
		$Priceline = new Price($_GET['id']);
		if ($Priceline->inventory != "on") die('0');
		if ((int)$_GET['stock'] < 0) die('0');
		$Priceline->stock = $_GET['stock'];
		$Priceline->save();
		echo "1";
		exit();
	}
开发者ID:robbiespire,项目名称:paQui,代码行数:10,代码来源:Ajax.php


注:本文中的Price::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。