當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::getPrice方法代碼示例

本文整理匯總了PHP中Item::getPrice方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getPrice方法的具體用法?PHP Item::getPrice怎麽用?PHP Item::getPrice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Item的用法示例。


在下文中一共展示了Item::getPrice方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isSatisfiedBy

 /**
  * Checks if Item price falls between bounds
  *
  * @param Item $item
  *
  * @return bool
  */
 public function isSatisfiedBy(Item $item)
 {
     if (!empty($this->maxPrice) && $item->getPrice() > $this->maxPrice) {
         return false;
     }
     if (!empty($this->minPrice) && $item->getPrice() < $this->minPrice) {
         return false;
     }
     return true;
 }
開發者ID:boiler256,項目名稱:DesignPatternsPHP,代碼行數:17,代碼來源:PriceSpecification.php

示例2: isSatisfiedBy

 public function isSatisfiedBy(Item $item) : bool
 {
     if ($this->maxPrice !== null && $item->getPrice() > $this->maxPrice) {
         return false;
     }
     if ($this->minPrice !== null && $item->getPrice() < $this->minPrice) {
         return false;
     }
     return true;
 }
開發者ID:paul-schulleri,項目名稱:DesignPatternsPHP,代碼行數:10,代碼來源:PriceSpecification.php

示例3: 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

示例4: canAddItem

 /**
  * Check whether Item can be added
  * 
  * @param Item $item
  * 
  * @return boolean
  */
 public function canAddItem(Item $item)
 {
     if ($this->getTotalPrice() + $item->getPrice() > $this->maxPricePerPackage) {
         return false;
     } else {
         return true;
     }
 }
開發者ID:dermo666,項目名稱:shippingCostExercise,代碼行數:15,代碼來源:Package.php

示例5: 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

示例6: 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

示例7: Item

<?php

// Start by assuming the transaction operations will all succeed
$success = TRUE;
// Give the POSTed item ID a friendly variable name
$itemID = filter_var($_POST['itemid'], FILTER_VALIDATE_INT);
//$participant = new Participant();
//$buyerID = $participant->getParticipantKey();
// Retrieve the item seller and price using some fictitious item class
$item = new Item();
$sellerID = $item->getItemOwner($itemID);
$price = $item->getPrice($itemID);
// Instantiate the mysqli class
$db = new mysqli("localhost", "website", "secret", "chapter37");
// Disable the autocommit feature
$db->autocommit(FALSE);
// Debit buyer's account
$stmt = $db->prepare("UPDATE participants SET cash = cash - ? WHERE id = ?");
$stmt->bind_param('di', $price, $buyerID);
$stmt->execute();
if ($db->affected_rows != 1) {
    $success = FALSE;
}
// Credit seller's account
$query = $db->prepare("UPDATE participants SET cash = cash + ? WHERE id = ?");
$stmt->bind_param('di', $price, $sellerID);
$stmt->execute();
if ($db->affected_rows != 1) {
    $success = FALSE;
}
// Update trunk item ownership. If it fails, set $success to FALSE
開發者ID:alannet,項目名稱:example,代碼行數:31,代碼來源:listing37_1.php

示例8: Item

     break;
 case "getItemByName":
     $item = new Item();
     print json_encode($item->getItemByName($_POST["name"]));
     break;
 case "getItemByNameWithPrice":
     $item = new Item();
     print json_encode($item->getItemByNameWithPrice($_POST["idcustomer"], $_POST["name"]));
     break;
 case "getItemLowestCost":
     $item = new Item();
     print $item->getLowestCost($_POST["iditem"]);
     break;
 case "getItemPrice":
     $item = new Item();
     print $item->getPrice($_POST["idPriceList"], $_POST["iditem"]);
     break;
 case "getItemQuantity":
     $item = new Item();
     print $item->getQuantity($_POST["iditem"]);
     break;
 case "saveInventory":
     $item = new Item();
     $max = $_POST["max"];
     $items = array();
     for ($i = 0; $i <= $max; $i++) {
         if (isset($_POST["hidItem" . $i]) && $_POST["hidItem" . $i] != "") {
             //shouldn't be empty
             $items[] = array("iditem" => $_POST["hidItem" . $i], "itemName" => $_POST["txtItem" . $i], "system" => $_POST["hidSystem" . $i], "manual" => $_POST["txtManual" . $i], "virtualStock" => $_POST["virtualStock" . $i]);
         }
     }
開發者ID:Edgargm87,項目名稱:efapcom,代碼行數:31,代碼來源:ItemController.php

示例9: update

    public function update(Item $item)
    {
        $idCategory = $item->getCategory()->getId();
        $id = intval($id);
        $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());
        $query = '	UPDATE item
							SET name=' . $name . ',
								price=' . $price . ',
								stock=' . $stock . ',
								image=' . $image . ',
								description=' . $description . ',
								id_category=' . $idCategory . '
							WHERE id=' . $id;
        $res = $this->db->exec($query);
        if ($res) {
            $id = $this->db->lastInsertId();
            if ($id) {
                return $this->findByID($id);
            } else {
                throw new Exception('Internal server Error');
            }
        }
    }
開發者ID:dispxxx,項目名稱:leshop,代碼行數:27,代碼來源:ItemManager.class.php

示例10: testDiscountTotalPriceOver10000

 public function testDiscountTotalPriceOver10000()
 {
     $item = new Item('RedBull', '240', '2011-07', '100');
     $number = 77;
     $item_price = $item->getPrice() * $number;
     $this->cart->addToCart($item, $number);
     $delivery_price = 0;
     $this->cart->setDeliveryType('hurry');
     $expected = $item_price + $delivery_price;
     $this->assertEquals($expected, $this->cart->getTotalPrice());
 }
開發者ID:nishigori,項目名稱:tddbc_tokyo_1.7_for_PHP_testCode,代碼行數:11,代碼來源:ShoppingCartTest.php


注:本文中的Item::getPrice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。