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


PHP Product::setPrice方法代码示例

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


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

示例1: getAdminInterface

 public function getAdminInterface()
 {
     $st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name";
     $products = Database::singleton()->query_fetch_all($st);
     $formPath = "/admin/EComm&section=Plugins&page=ChangeProductPrice";
     $form = new Form('change_product_prices', 'post', $formPath);
     if ($form->validate() && isset($_REQUEST['submit'])) {
         foreach ($products as $product) {
             $ECommProduct = new Product($product['product_id']);
             $ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]);
             $ECommProduct->save();
         }
         return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>";
     }
     $oldSupplier = 0;
     $currentSupplier = 0;
     $defaultValue = array();
     foreach ($products as $product) {
         $currentSupplier = $product['supplier_id'];
         if ($oldSupplier != $currentSupplier) {
             $form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>');
         }
         $form->addElement('text', 'product_' . $product['product_id'], $product['product_name']);
         $defaultValue['product_' . $product['product_id']] = $product['product_price'];
         $oldSupplier = $product['supplier_id'];
     }
     $form->addElement('submit', 'submit', 'Submit');
     $form->setDefaults($defaultValue);
     return $form->display();
 }
开发者ID:anas,项目名称:feedstore,代码行数:30,代码来源:ChangeProductPrice.php

示例2: getOrderByOrderTime

 public function getOrderByOrderTime($campaignId, $orderStatTime, $orderEndTime)
 {
     if (empty($campaignId) || empty($orderStatTime) || empty($orderEndTime)) {
         echo "campaignId ,orderStatTime or orderEndTime is null";
         exit;
     }
     $sql = "SELECT p.order_id,order_sn,add_time,order_status,pay_status,pay_name,order_time,cid,wi,order_status,pay_status,pay_name,shipping_fee,surplus,bonus,order_amount FROM `cps` as p LEFT OUTER JOIN ecs_order_info as i on i.order_id=p.order_id where p.cid=" . $campaignId . " and order_time>" . $orderStatTime . " and order_time<" . $orderEndTime;
     $dborder = $GLOBALS['db']->getAll($sql);
     if (empty($dborder)) {
         return NULL;
     }
     foreach ($dborder as $k => $v) {
         $order = new Order();
         $order->setOrderNo($v['order_sn']);
         $order_time = date('Y-m-d H:i:s', $v['order_time']);
         $order->setOrderTime($order_time);
         // 设置下单时间
         $order->setUpdateTime($order_time);
         // 设置订单更新时间,如果没有下单时间,要提前对接人提前说明
         $order->setCampaignId($v['cid']);
         // 测试时使用"101",正式上线之后活动id必须要从数据库里面取
         $order->setFeedback($v['wi']);
         $order->setFare($v['shipping_fee']);
         $order->setFavorable($v['bonus'] + $v['surplus']);
         //$orderStatus = new OrderStatus();
         //$orderStatus -> setOrderNo($order -> getOrderNo());
         $order->setOrderStatus($v['order_status']);
         // 设置订单状态
         $order->setPaymentStatus($v['pay_status']);
         // 设置支付状态
         $order->setPaymentType($v['pay_name']);
         // 支付方式
         $sql = "select * from ecs_order_goods where order_id=" . $v['order_id'] . " and goods_price>100";
         $order_goods = $GLOBALS['db']->getAll($sql);
         //echo "<pre>";print_r($order_goods);
         foreach ($order_goods as $k1 => $v1) {
             $pro = new Product();
             //$pro -> setOrderNo($order -> getOrderNo());
             $pro->setProductNo($v1['goods_sn']);
             $pro->setName($v1['goods_name']);
             $pro->setCategory("蛋糕");
             $pro->setCommissionType("");
             $pro->setAmount($v1['goods_number']);
             $a = number_format($v1['goods_price'] * (1 - ($v['bonus'] + $v['surplus']) / ($v['bonus'] + $v['surplus'] + $v['order_amount'])), 2, ".", "");
             $pro->setPrice($a);
             $products[] = $pro;
         }
         $order->setProducts($products);
         $orderlist[] = $order;
         $products = array();
     }
     //print_r($orderlist);
     //echo json_encode($orderlist);
     return $orderlist;
 }
开发者ID:songtaiwu,项目名称:m-cmsold,代码行数:55,代码来源:Dto.php

示例3: getProducts

 /**
  * @param integer $categoryId
  * @return Product[]
  */
 public static function getProducts($categoryId)
 {
     $resource = Database::query("SELECT id, name, price FROM product WHERE category_id = {$categoryId}");
     $products = array();
     while ($row = mysql_fetch_assoc($resource)) {
         $product = new Product($row['id'], $row['name']);
         $product->setPrice($row['price']);
         $products[] = $product;
     }
     return $products;
 }
开发者ID:andomiell,项目名称:electro-centr,代码行数:15,代码来源:shop.php

示例4: createAction

 public function createAction()
 {
     $article = new Product();
     $article->setTitle('Trophée Descartes 2013');
     $article->setPrice('6/7 Arvil');
     $article->setContent('Lorem ipsum dolor');
     $em = $this->getDoctrine()->getManager();
     $em->persist($article);
     $em->flush();
     return new Response('Id du produit créé : ' . $article->getId());
 }
开发者ID:Association-Vie-Etudiante-Descartes,项目名称:site-aved-kelian,代码行数:11,代码来源:DefaultController.php

示例5: map

 public static function map(Product $product, array $properties)
 {
     if (array_key_exists('product_id', $properties)) {
         $product->setProductId($properties['product_id']);
     }
     if (array_key_exists('product_name', $properties)) {
         $product->setProductName($properties['product_name']);
     }
     if (array_key_exists('price', $properties)) {
         $product->setPrice($properties['price']);
     }
 }
开发者ID:angela-chan,项目名称:advanced-client-side-project,代码行数:12,代码来源:productMapper.php

示例6: testCalculatePrices

 public function testCalculatePrices()
 {
     // Create new prices
     $this->product->setPrice(self::getApplication()->getDefaultCurrencyCode(), $defaultPrice = 1);
     $this->product->save();
     // Just check that prices for other currencies are generated
     $this->product->loadSpecification();
     $pricing = $this->product->getPricingHandler();
     $prices = $pricing->toArray(ProductPricing::BOTH);
     foreach (self::getApplication()->getCurrencyArray(!LiveCart::INCLUDE_DEFAULT) as $currencyCode) {
         $this->assertTrue(isset($prices[ProductPricing::CALCULATED][$currencyCode]) && $prices[ProductPricing::CALCULATED][$currencyCode] > 0);
         $this->assertFalse(isset($prices[ProductPricing::DEFINED][$currencyCode]));
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:14,代码来源:ProductPricingTest.php

示例7: getProduct

 public function getProduct($product_id)
 {
     $db = Database::getDB();
     $query = "SELECT * FROM products\n                  WHERE productID = '{$product_id}'";
     $result = $db->query($query);
     $row = $result->fetch();
     $category = CategoryDB::getCategory($row['categoryID']);
     $product = new Product();
     $product->setCategory($category);
     $product->setId($row['productID']);
     $product->setCode($row['productCode']);
     $product->setName($row['productName']);
     $product->setPrice($row['listPrice']);
     return $product;
 }
开发者ID:j-jm,项目名称:web182,代码行数:15,代码来源:product_db.php

示例8: createProducts

 private function createProducts()
 {
     $ipad = new Product();
     $ipad->setId(1);
     $ipad->setDescription('A brand new 16 GIGA iPad');
     $ipad->setPrice('499.00');
     $this->allProducts[] = $ipad;
     $iphone = new Product();
     $iphone->setId(2);
     $iphone->setDescription('A brand new 32 GIGA iPhone');
     $iphone->setPrice(599.0);
     $this->allProducts[] = $iphone;
     $ipod = new Product();
     $ipod->setId(3);
     $ipod->setDescription('A brand new 8 GIGA iPod');
     $ipod->setPrice(299.0);
     $this->allProducts[] = $ipod;
 }
开发者ID:db80,项目名称:ovo-container,代码行数:18,代码来源:ProductRepository.php

示例9: testChildProduct

 public function testChildProduct()
 {
     $this->product->setPrice($this->usd, 20);
     $this->product->shippingWeight->set(200);
     $this->product->save();
     $child = $this->product->createChildProduct();
     $root = Category::getRootNode();
     $root->reload();
     $productCount = $root->totalProductCount->get();
     // in array representation, parent product data is used where own data is not set
     $array = $child->toArray();
     $this->assertEquals($array['name_en'], $this->product->getValueByLang('name', 'en'));
     // auto-generated SKU is based on parent SKU
     $child->save();
     $this->assertEquals($child->sku->get(), $this->product->sku->get() . '-1');
     // category counters should not change
     $root->reload();
     $this->assertEquals($root->totalProductCount->get(), $productCount);
     // parent product price used if not defined
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd));
     // parent shipping weight used if not defined
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight());
     // add/substract parent prices/shipping weights
     $child->setChildSetting('test', 'value');
     $this->assertEquals($child->getChildSetting('test'), 'value');
     // prices
     $child->setChildSetting('price', Product::CHILD_ADD);
     $child->setPrice($this->usd, 5);
     $this->assertEquals(20, $this->product->getPrice($this->usd));
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) + 5);
     $child->setChildSetting('price', Product::CHILD_SUBSTRACT);
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) - 5);
     $child->setChildSetting('price', Product::CHILD_OVERRIDE);
     $this->assertEquals($child->getPrice($this->usd), 5);
     // shipping weight
     $child->setChildSetting('weight', Product::CHILD_ADD);
     $child->shippingWeight->set(5);
     $this->assertEquals(200, $this->product->getShippingWeight());
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() + 5);
     $child->setChildSetting('weight', Product::CHILD_SUBSTRACT);
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() - 5);
     $child->setChildSetting('weight', Product::CHILD_OVERRIDE);
     $this->assertEquals($child->getShippingWeight(), 5);
 }
开发者ID:saiber,项目名称:livecart,代码行数:44,代码来源:ProductTest.php

示例10: generateProducts

 public static function generateProducts()
 {
     //read in xml document(products)
     $doc = simplexml_load_file(APPLICATION_PATH . '/../products.xml');
     foreach ($doc->category as $cat) {
         $categoryObj = new Category();
         $categoryObj->setUrlKey($cat->urlkey);
         $categoryObj->setName($cat->name);
         $categoryObj->save();
     }
     foreach ($doc->product as $product) {
         $productObj = new Product();
         $productObj->setName($product->name);
         $productObj->setPrice($product->price);
         $productObj->setSku($product->sku);
         $productObj->setDateCreated(date('d-m-Y H:i:s', time()));
         $productObj->setUrlKey($product->urlkey);
         $productObj->setProductImage($product->image);
         $productObj->setCategoryId($product->category);
         $productObj->save();
     }
 }
开发者ID:Heisenberg87,项目名称:zendshop,代码行数:22,代码来源:ProductGeneration.php

示例11: create

 public function create(SubCategory $sub_category, $name, $description, $price, $img, $stock)
 {
     $errors = array();
     $product = new Product($this->db);
     try {
         $product->setSubCategory($sub_category);
         $product->setName($name);
         $product->setDescription($description);
         $product->setPrice($price);
         $product->setImg($img);
         $product->setStock($stock);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     $errors = array_filter($errors, function ($val) {
         return $val !== true;
     });
     if (count($errors) == 0) {
         $idSubCategory = intval($product->getIdSubCategory());
         $name = $this->db->quote($product->getName());
         $description = $this->db->quote($product->getDescription());
         $price = $this->db->quote($product->getPrice());
         $img = $this->db->quote($product->getImg());
         $stock = $this->db->quote($product->getStock());
         $query = "INSERT INTO product(id_sub_category, name, description, price, img, stock) VALUES('" . $idSub_category . "', " . $name . ", " . $description . ", " . $price . ", " . $img . ", " . $stock . ")";
         $res = $this->db->exec($query);
         if ($res) {
             $id = $this->db->lastInsertId();
             if ($id) {
                 return $this->findById($id);
             } else {
                 return "Internal Server error";
             }
         }
     } else {
         return $errors;
     }
 }
开发者ID:berserkr1,项目名称:e-commerce,代码行数:38,代码来源:ProductManager.class.php

示例12: foreach

     // 设置订单状态
     $cps->setPaymentStatus($order['pay_status']);
     // 设置支付状态
     $cps->setPaymentType($order['pay_name']);
     // 支付方式
     foreach ($cart_goods as $k => $v) {
         if ($v['goods_price'] > 0) {
             $pro = new Product();
             // $pro2 -> setOrderNo($order -> getOrderNo());
             $pro->setProductNo($v['goods_sn']);
             $pro->setName($v['goods_name']);
             $pro->setCategory("蛋糕");
             $pro->setCommissionType("");
             $pro->setAmount($v['goods_number']);
             $a = number_format($v['goods_price'] * (1 - ($order['bonus'] + $order['surplus']) / ($order['bonus'] + $order['surplus'] + $order['order_amount'])), 2, ".", "");
             $pro->setPrice($a);
             $products[] = $pro;
         }
     }
     $cps->setProducts($products);
     //var_dump(get_object_vars($cps));
     $sender = new Sender();
     $sender->setOrder($cps);
     $sender->sendOrder();
     $ordertime = $order['add_time'] + 8 * 3600;
     $sql = "INSERT INTO cps ( " . "order_id,src,channel,cid,wi,order_time)" . " values('{$new_order_id}','emar','cps'," . $arr[2] . ",'" . $arr[3] . "','" . $ordertime . "') ";
     $db->query($sql);
 }
 /* 修改拍卖活动状态 
     if ($order['extension_code']=='auction')
     {
开发者ID:songtaiwu,项目名称:m-cmsold,代码行数:31,代码来源:flow.php

示例13: Product

<?php

require_once 'Product.php';
require_once 'Tool.php';
require_once 'Electronic.php';
$form = new Product();
if (isset($_POST['submit'])) {
    $form->setTitle($_POST['title']);
    $form->setDescription($_POST['description']);
    $form->setPrice($_POST['price']);
    $form->saveProduct();
}
开发者ID:bobroadway,项目名称:php_course_work,代码行数:12,代码来源:generic.php

示例14: Customer

<?php

require_once 'includes/ShoppingCart.php';
require_once 'includes/Product.php';
require_once 'includes/Customer.php';
session_start();
if (!isset($_SESSION['customer'])) {
    //todo fix
    $customer = new Customer(rand(1, 1000));
    $sc = new ShoppingCart(rand(1, 1000));
    $customer->setShoppingCart(rand(1, 1000));
    $_SESSION['customer'] = serialize($customer);
}
$customer = unserialize($_SESSION['customer']);
$product = new Product($_GET['product']);
$product->setPrice($_GET['price']);
$customer->getShoppingCart()->setProduct([$product->getName() => $product]);
$_SESSION['customer'] = serialize($customer);
?>
<html>
<header>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
  <link rel="stylesheet" href="includes/css/prism.css">
  <script src="includes/js/prism.js"></script>
  <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
  <title>CityAds implementation via third party services (Google Tag Manager, Shopify). Molanco Team</title>

</header>
开发者ID:AngelAlvarado,项目名称:CityAds,代码行数:30,代码来源:detalle_producto.php

示例15: processRecord

 protected function processRecord(Product $product)
 {
     $act = $this->getAction();
     $field = $this->getField();
     if ('manufacturer' == $act) {
         $product->manufacturer->set($this->params['manufacturer']);
     } else {
         if ('price' == $act) {
             $product->setPrice($this->params['baseCurrency'], $this->params['price']);
         } else {
             if (in_array($act, array('inc_price', 'multi_price', 'div_price'))) {
                 $actions = array('inc_price' => 'increasePriceByPercent', 'multi_price' => 'multiplyPrice', 'div_price' => 'dividePrice');
                 $action = $actions[$act];
                 $pricing = $product->getPricingHandler();
                 foreach ($this->params['currencies'] as $currency) {
                     if ($pricing->isPriceSet($currency)) {
                         $p = $pricing->getPrice($currency);
                         $p->{$action}($this->params['inc_price_value'], $this->params['inc_quant_price']);
                         $p->save();
                     }
                 }
             } else {
                 if ('inc_stock' == $act) {
                     $product->stockCount->set($product->stockCount->get() + $this->request->get($act));
                 } else {
                     if ('addRelated' == $act) {
                         $product->addRelatedProduct($this->params['relatedProduct']);
                     } else {
                         if ('copy' == $act) {
                             $cloned = clone $product;
                             $cloned->category->set($this->params['category']);
                             $cloned->save();
                         } else {
                             if ('addCat' == $act) {
                                 // check if the product is not assigned to this category already
                                 $relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID()));
                                 if (!$relation->isExistingRecord() && $product->category->get() !== $category) {
                                     $relation->save();
                                 }
                             } else {
                                 if ('theme' == $act) {
                                     $instance = CategoryPresentation::getInstance($product);
                                     $instance->theme->set($this->params['theme']);
                                     $instance->save();
                                 } else {
                                     if ('shippingClass' == $act) {
                                         $product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false));
                                     } else {
                                         if ('taxClass' == $act) {
                                             $product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false));
                                         } else {
                                             if (substr($act, 0, 13) == 'set_specField') {
                                                 $this->params['request']->remove('manufacturer');
                                                 $product->loadRequestData($this->params['request']);
                                             } else {
                                                 if (substr($act, 0, 16) == 'remove_specField') {
                                                     $this->params['request']->remove('manufacturer');
                                                     if ($this->params['field']->isMultiValue->get()) {
                                                         // remove only selected multi-select options
                                                         $product->loadRequestData($this->params['request']);
                                                     } else {
                                                         $product->removeAttribute($this->params['field']);
                                                     }
                                                 } else {
                                                     parent::processRecord($product);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:78,代码来源:ProductMassActionProcessor.php


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