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


PHP Item::setPrice方法代码示例

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


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

示例1: test_accessors

 public function test_accessors()
 {
     /** === Test Data === */
     $STOCK_ITEM_REF = 'stock item ref';
     $PRICE = 'price';
     /** === Call and asserts  === */
     $this->obj->setStockItemRef($STOCK_ITEM_REF);
     $this->obj->setPrice($PRICE);
     $this->assertEquals($STOCK_ITEM_REF, $this->obj->getStockItemRef());
     $this->assertEquals($PRICE, $this->obj->getPrice());
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_warehouse,代码行数:11,代码来源:Item_Test.php

示例2: create

    public function create(Category $category, $name, $price, $stock, $image, $description)
    {
        $errors = array();
        $item = new Item($this->db);
        try {
            $item->setCategory($category);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setName($name);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setPrice($price);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setStock($stock);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setImage($image);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setDescription($description);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (count($errors) == 0) {
            $name = $this->db->quote($item->getName());
            $price = $this->db->quote($item->getPrice());
            $stock = $this->db->quote($item->getStock());
            $image = $this->db->quote($item->getImage());
            $description = $this->db->quote($item->getDescription());
            $idCategory = $item->getCategory()->getId();
            $query = '	INSERT INTO item (id_category, name, price, stock, image, description)
								VALUES(' . $idCategory . ',' . $name . ',' . $price . ',' . $stock . ',' . $image . ',' . $description . ')';
            $res = $this->db->exec($query);
            if ($res) {
                $id = $this->db->lastInsertId();
                if ($id) {
                    return $this->readByID($id);
                } else {
                    throw new Exception('Internal server Error');
                }
            }
        }
    }
开发者ID:dispxxx,项目名称:leshop,代码行数:54,代码来源:ItemManager.class.php

示例3: testSetGetPrice

 public function testSetGetPrice()
 {
     // Arrange
     $item = new Item();
     $item->setPrice(2.5);
     $expectedResult = 2.5;
     // Act
     $result = $item->getPrice();
     // Assert
     $this->assertEquals($result, $expectedResult);
 }
开发者ID:Owen66,项目名称:KBK-WebSite,代码行数:11,代码来源:ItemTest.php

示例4: buildRawExamples

 public static function buildRawExamples()
 {
     // Order persons
     echo ' 8: Initial data: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Inserting an order person
     $newOrderPerson = new \OrderPerson();
     $newOrderPerson->setEmail('lilian.tikk03@gmail.com');
     $newOrderPerson->setFirstName('lilian');
     $newOrderPerson->setLastName('tikk');
     $newOrderPerson->insert();
     echo ' 10: After insertion: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Querying full data of an order person
     $orderPerson = new OrderPerson();
     $orderPerson->setId(3);
     $orderPerson->setCompleteOrderPerson();
     echo ' 20: Order person #3: <pre>';
     var_dump($orderPerson);
     echo '</pre>';
     // Updating data of an order person
     $orderPerson->setAddress('Pärnu, Pärnu');
     $orderPerson->update();
     echo ' 24: After updating the order person #3: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Deleting the order person #2
     $orderPerson = new \OrderPerson();
     $orderPerson->setId(2);
     $orderPerson->delete();
     echo ' 43: After deleting the order person #2: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Items
     require_once dirname(__FILE__) . '/Item.php';
     $item = new Item();
     $item->setId(1);
     $item->setName('õun');
     $item->setPrice(1.0);
     $item->setAmount(20.0);
     $item->insertItem($item);
     $item = new \shiporder\Item();
     $item->setId(2);
     $item->setName('pirn');
     $item->setPrice(2.0);
     $item->setAmount(10.0);
     $item->insertItem($item);
     $items = $item->getItems();
     var_dump($items);
 }
开发者ID:piiskop,项目名称:pstk,代码行数:52,代码来源:OrderPersonController.php

示例5: createAction

 function createAction(Request $request, Application $app)
 {
     if (null === ($user = $app['session']->get('user'))) {
         return $app->redirect('/login');
     }
     $newItem = new Item();
     $newItem->setName($request->get('name'));
     $newItem->setDescription($request->get('description'));
     $newItem->setPrice($request->get('price'));
     $newItem->setCalories($request->get('calories'));
     $newItem->setAllergyInformation($request->get('allergyInformation'));
     $em = $app['orm.em'];
     $categoryRepository = $em->getRepository('Category');
     $Category = $categoryRepository->find($request->get('category'));
     $newItem->setCategory($Category);
     $file = $request->files->get('photo');
     $newItem->setPhoto($file->getClientOriginalName());
     $file = $request->files->get('photo');
     $file->move(__DIR__ . '/../public/img', $file->getClientOriginalName());
     $em->persist($newItem);
     $em->flush();
     return $app->redirect('/itemAdmin');
 }
开发者ID:Owen66,项目名称:KBK-WebSite,代码行数:23,代码来源:ItemController.php

示例6: setItemsByData

 /**
  * @param array $data
  */
 public function setItemsByData($data)
 {
     foreach ($data as $itemData) {
         $item = new Item();
         if (isset($itemData['item'])) {
             $itemData = array_merge($itemData, $itemData['item']);
         }
         // stop if quantity is smaller than 0
         if ($this->getProperty('quantity', $itemData, 0) < 1) {
             continue;
         }
         $item->setPrice($this->getProperty('price', $itemData, 0));
         $item->setQuantity($this->getProperty('quantity', $itemData));
         $item->setQuantityUnit($this->getProperty('quantityUnit', $itemData));
         $item->setAddress($this->getProperty('address', $itemData));
         $item->setUseProductsPrice($this->getProperty('useProductsPrice', $itemData));
         $item->setDeliveryDate($this->getProperty('deliveryDate', $itemData));
         $item->setNetShippingCosts($this->getProperty('netShippingCosts', $itemData));
         if (isset($itemData['product'])) {
             $product = new Product($this->getProperty('id', $itemData['product']));
             $item->setProduct($product);
         }
         // set account to customer
         if (isset($itemData['account']) && !isset($itemData['customer'])) {
             $itemData['customer'] = $itemData['account'];
         }
         if (isset($itemData['customer'])) {
             $customer = new Account($this->getProperty('id', $itemData['customer']), $this->getProperty('name', $itemData['customer']));
             $item->setCustomerAccount($customer);
         }
         if (isset($itemData['supplier'])) {
             $customer = new Account($this->getProperty('id', $itemData['supplier']), $this->getProperty('name', $itemData['supplier']));
             $item->setSupplierAccount($customer);
         }
         // add to items array
         $this->items[] = $item;
         // create ordered item arrays
         $customerId = 0;
         $supplierId = 0;
         if ($item->getCustomerAccount()) {
             $customerId = $item->getCustomerAccount()->getId();
         }
         if ($item->getSupplierAccount()) {
             $supplierId = $item->getSupplierAccount()->getId();
         }
         $this->customerItems[$customerId][] = $item;
         $this->customerSupplierItems[$customerId]['supplierItems'][$supplierId][] = $item;
     }
 }
开发者ID:sulu,项目名称:sulu-sales,代码行数:52,代码来源:TransitionData.php

示例7: create

 /**
  * @param Subcategory $subcategory
  * @param $name
  * @param $descr
  * @param $short_descr
  * @param $price
  * @param $stock
  * @return array
  * @throws Exception
  */
 public function create(Subcategory $subcategory, $name, $descr, $short_descr, $price, $stock)
 {
     $errors = array();
     $item = new Item($this->db);
     try {
         $item->setName($name);
         $item->setDescription($descr);
         $item->setShortDescription($short_descr);
         $item->setPrice($price);
         $item->setStock($stock);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     if (count($errors) == 0) {
         $name = $this->db->quote($item->getName());
         $description = $this->db->quote($item->getDescription());
         $shortDescription = $this->db->quote($item->getShortDescription());
         $price = $this->db->quote($item->getPrice());
         $stock = $this->db->quote($item->getStock());
         $query = "  INSERT INTO item(id_subcategory, name, descr, short_descr, price, stock)\n                               VALUES(" . $subcategory->getId() . ", " . $name . ", " . $description . ", " . $shortDescription . ", " . $price . ", " . $stock . ")";
         $data = $this->db->exec($query);
         if ($data) {
             $id = $this->db->lastInsertId();
             if ($id) {
                 try {
                     return $this->findById($id);
                 } catch (Exception $e) {
                     $errors[] = $e->getMessage();
                     return $errors;
                 }
             } else {
                 throw new Exception('Last insert error');
             }
         } else {
             throw new Exception('Db error');
         }
     } else {
         return $errors;
     }
 }
开发者ID:CreepingPanda,项目名称:FennecPlusUltra,代码行数:50,代码来源:ItemManager.class.php

示例8: initializeWithRawData

 /**
  * Initialize the object with raw data
  *
  * @param $data
  * @return Item
  */
 public static function initializeWithRawData($data)
 {
     $item = new Item();
     if (isset($data['description'])) {
         $item->setDescription($data['description']);
     }
     if (isset($data['amount'])) {
         $item->setAmount($data['amount']);
     }
     if (isset($data['price'])) {
         $item->setPrice($data['price']);
     }
     if (isset($data['vat'])) {
         $item->setVat($data['vat']);
     }
     if (isset($data['reference_id'])) {
         $item->setReferenceId($data['reference_id']);
     }
     if (isset($data['total_without_vat'])) {
         $item->setTotalWithoutVat($data['total_without_vat']);
     }
     if (isset($data['total_vat'])) {
         $item->setTotalVat($data['total_vat']);
     }
     if (isset($data['total_with_vat'])) {
         $item->setTotalWithVat($data['total_with_vat']);
     }
     if (isset($data['discount'])) {
         $item->setDiscount($data['discount']);
     }
     if (isset($data['percentage'])) {
         $item->setDiscountIsPercentage($data['percentage']);
     }
     if (isset($data['discount_description'])) {
         $item->setDiscountDescription($data['discount_description']);
     }
     return $item;
 }
开发者ID:sumocoders,项目名称:factr,代码行数:44,代码来源:Item.php

示例9: getItems

 static function getItems(Feed &$feed)
 {
     $fid = $feed->getId();
     $text = $feed->getMessage();
     static::doParse($text);
     $assocs = static::$array;
     $result = array();
     foreach ($assocs as $index => $assoc) {
         $item = new Item();
         $item->setId($fid . '_' . $index);
         $item->setFeed($feed);
         if (isset($assoc['type'])) {
             $item->setType($assoc['type']);
         } else {
             $item->setType('GLOBAL');
         }
         if (isset($assoc['description'])) {
             $item->setDescription($assoc['description']);
         }
         if (isset($assoc['global'])) {
             $item->setGlobal($assoc['global']);
         }
         if (isset($assoc['name'])) {
             $item->setName($assoc['name']);
         }
         if (isset($assoc['note'])) {
             $item->setNote($assoc['note']);
         }
         if (isset($assoc['price_digit'])) {
             $item->setPrice($assoc['price_digit']);
         }
         if (isset($assoc['price'])) {
             $item->setPriceStr($assoc['price']);
         }
         if (isset($assoc['status'])) {
             $item->setStatus($assoc['status']);
         }
         $result[] = $item;
     }
     if (!$result) {
         $item = new Item();
         $item->setId($fid . '_0');
         $item->setFeed($feed);
         $item->setType('GLOBAL');
         $item->setGlobal($text);
         $result[] = $item;
     }
     return $result;
 }
开发者ID:hchsiao,项目名称:xdbrowser-DEPRECATED,代码行数:49,代码来源:ItemFactory.php


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