本文整理汇总了PHP中Mage_Sales_Model_Quote_Item::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item::getChildren方法的具体用法?PHP Mage_Sales_Model_Quote_Item::getChildren怎么用?PHP Mage_Sales_Model_Quote_Item::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item::getChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isItemInventoried
/**
* Test if the item needs to have its quantity checked for available
* inventory.
* @param Mage_Sales_Model_Quote_Item $item The item to check
* @return bool True if inventory is managed, false if not
*/
public function isItemInventoried(Mage_Sales_Model_Quote_Item $item)
{
// never consider a child product as inventoried, allow the parent deal
// with inventory and let the child not need to worry about it as the parent
// will be the item to keep track of qty being ordered.
// Both checks needed as child items will not have a parent item id prior
// to being saved and a parent item prior to being added to the parent (e.g.
// immediately after being loaded from the DB).
if ($item->getParentItemId() || $item->getParentItem()) {
return false;
}
// when dealing with parent items, if any child of the product is managed
// stock, consider the entire item as managed stock - allows for the parent
// config product in the quote to deal with inventory while allowing child
// products to not care individually
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $childItem) {
$childStock = $childItem->getProduct()->getStockItem();
if ($this->isManagedStock($childStock)) {
// This Parent is inventoried. Child's ROM setting is 'No backorders', and Manage Stock check hasn't been manually overridden
return true;
}
}
// if none of the children were managed stock, the parent is not inventoried
return false;
}
return $this->isManagedStock($item->getProduct()->getStockItem());
}
示例2: _getStdWeightQtyTotals
/**
* Gets the item information for standard items or child items of configurable products
*
* @param Mage_Sales_Model_Quote_Item $item
* @param bool $cartFreeShipping
* @return Webshopapps_Wsacommon_Model_Totals
*/
protected function _getStdWeightQtyTotals($item, $cartFreeShipping)
{
$finalTotals = new Webshopapps_Wsacommon_Model_Totals();
$addressWeight = 0;
$addressQty = 0;
$freeMethodWeight = 0;
if ($item->getHasChildren() && ($item->isShipSeparately() || $item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)) {
foreach ($item->getChildren() as $child) {
if ($child->getProduct()->isVirtual()) {
continue;
}
$addressQty += $item->getQty() * $child->getQty();
$itemWeight = $child->getWeight();
$itemQty = $child->getTotalQty();
$rowWeight = $itemWeight * $itemQty;
if ($cartFreeShipping || $child->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($child->getFreeShipping())) {
$freeQty = $child->getFreeShipping();
if ($itemQty > $freeQty) {
$rowWeight = $itemWeight * ($itemQty - $freeQty);
} else {
$rowWeight = 0;
}
}
$freeMethodWeight += $rowWeight;
$addressWeight += $rowWeight;
}
} else {
$addressQty += $item->getQty();
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($cartFreeShipping || $item->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($item->getFreeShipping())) {
$freeQty = $item->getFreeShipping();
if ($item->getQty() > $freeQty) {
$rowWeight = $itemWeight * ($item->getQty() - $freeQty);
} else {
$rowWeight = 0;
}
}
$freeMethodWeight += $rowWeight;
}
$finalTotals->setWeight($addressWeight);
$finalTotals->setFreeMethodWeight($freeMethodWeight);
// TODO This wasnt in original, needs checking
$finalTotals->setQty($addressQty);
return $finalTotals;
}
示例3: validateStock
/**
* Validate stock of a quoteItem
*
* @param Mage_Sales_Model_Quote_Item $item
* @param float $priceInclTax
* @param float $priceExclTax
*
* @return ShopgateCartItem $result
*/
public function validateStock(Mage_Sales_Model_Quote_Item $item, $priceInclTax, $priceExclTax)
{
$product = $item->getProduct();
/** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = $product->getStockItem();
$errors = array();
$isBuyable = true;
$qtyBuyable = null;
foreach ($item->getChildren() as $childItem) {
/** @var Mage_Catalog_Model_Product $childProduct */
$childProduct = $childItem->getProduct();
/** @var Mage_CatalogInventory_Model_Stock_Item $childStock */
$childStock = $childProduct->getStockItem();
if ($childStock->getManageStock() && !$childProduct->isSaleable() && !$childStock->getBackorders()) {
$isBuyable = false;
$error = array();
$error['type'] = ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK;
$error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK);
$errors[] = $error;
} else {
if ($childStock->getManageStock() && !$childStock->checkQty($childItem->getQty()) && !$childStock->getBackorders()) {
$isBuyable = false;
$error = array();
$error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
$error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
$errors[] = $error;
if ($qtyBuyable == null || $qtyBuyable > $childStock->getQty()) {
$qtyBuyable = $childStock->getQty();
}
} else {
if (Mage::helper('shopgate/config')->getIsMagentoVersionLower1410()) {
$checkIncrements = Mage::helper('shopgate')->checkQtyIncrements($childStock, $childItem->getQty());
} else {
$checkIncrements = $childStock->checkQtyIncrements($childItem->getQty());
}
if ($childStock->getManageStock() && $checkIncrements->getHasError()) {
$isBuyable = false;
$error = array();
$error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
$error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
$errors[] = $error;
$stockItem->setQty((int) ($item->getQtyToAdd() / $stockItem->getQtyIncrements()) * $stockItem->getQtyIncrements());
}
}
}
}
$qtyBuyable = $qtyBuyable == null ? (int) $item->getQty() : (int) $qtyBuyable;
return Mage::helper('shopgate')->generateShopgateCartItem($product, $isBuyable, $qtyBuyable, $priceInclTax, $priceExclTax, $errors, (int) $stockItem->getQty());
}
示例4: deleteItem
/**
* Delete quote item. If it does not have identifier then it will be only removed from collection
*
* @param Mage_Sales_Model_Quote_Item $item
* @return Mage_Sales_Model_Quote
*/
public function deleteItem(Mage_Sales_Model_Quote_Item $item)
{
if ($item->getId()) {
$this->removeItem($item->getId());
} else {
$quoteItems = $this->getItemsCollection();
$items = array($item);
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $child) {
$items[] = $child;
}
}
foreach ($quoteItems as $key => $quoteItem) {
foreach ($items as $item) {
if ($quoteItem->compare($item)) {
$quoteItems->removeItemByKey($key);
}
}
}
}
return $this;
}
示例5: getProductInformationFromQuoteItem
public function getProductInformationFromQuoteItem(Mage_Sales_Model_Quote_Item $item, $additionalInformation = array())
{
$children = $item->getChildren();
return $this->_getProductInformationWork($item, $additionalInformation, count($children) > 0, $children);
}
示例6: _skip
/**
* determines if we should skip the items with special price or other (in futeure) conditions
*
* @param Mage_Sales_Model_Quote_Item $item
* @param Amasty_Promo_Model_Sales_Quote_Address $address
*
* @return bool
*/
protected function _skip($item, $address)
{
if (!Mage::getStoreConfig('ampromo/general/skip_special_price')) {
return false;
}
if ($item->getProductType() == 'bundle') {
return false;
}
if (is_null($this->_itemsWithDiscount) || count($this->_itemsWithDiscount) == 0) {
$productIds = array();
$this->_itemsWithDiscount = array();
foreach ($this->_getAllItems($address) as $addressItem) {
$productIds[] = $addressItem->getProductId();
}
if (!$productIds) {
return false;
}
$productsCollection = Mage::getModel('catalog/product')->getCollection()->addPriceData()->addAttributeToFilter('entity_id', array('in' => $productIds))->addAttributeToFilter('price', array('gt' => new Zend_Db_Expr('final_price')));
foreach ($productsCollection as $product) {
$this->_itemsWithDiscount[] = $product->getId();
}
}
if (Mage::getStoreConfig('ampromo/general/skip_special_price_configurable')) {
if ($item->getProductType() == "configurable") {
foreach ($item->getChildren() as $child) {
if (in_array($child->getProductId(), $this->_itemsWithDiscount)) {
return true;
}
}
}
}
if (!in_array($item->getProductId(), $this->_itemsWithDiscount)) {
return false;
}
return true;
}
示例7: checkQuoteItemQty
/**
* override for changing the current stock qty based on the quote_item
* (this is a bad design from Magento, checkQuoteItemQty should receive the quoteItem in the original code too)
*
* @param mixed $qty
* @param mixed $summaryQty
* @param int $origQty
* @param Mage_Sales_Model_Quote_Item $quoteItem
*
* @return Varien_Object
*/
public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0, $quoteItem = null, $product = null)
{
if ($quoteItem && ITwebexperts_Payperrentals_Helper_Data::isReservationOnly($product) && (!$quoteItem->getChildren() || Mage::app()->getStore()->isAdmin())) {
$qtyOption = 1;
if ($quoteItem->getParentProductQty()) {
$qty = $quoteItem->getParentProductQty();
$qtyOption = $quoteItem->getParentProductQtyOption();
}
$quoteItemId = $quoteItem->getId();
if ($quoteItem->getParentItem() && $quoteItem->getParentItem()->getProduct()) {
if ($quoteItem->getParentItem()->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) {
$quoteItemId = $quoteItem->getParentItem()->getItemId();
}
}
$turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($product, $quoteItem);
list($startDate, $endDate) = array($turnoverArr['before'], $turnoverArr['after']);
$result = new Varien_Object();
$result->setHasError(false);
if (!is_numeric($qty)) {
$qty = Mage::app()->getLocale()->getNumber($qty);
}
/**
* Check quantity type
*/
$result->setItemIsQtyDecimal($this->getIsQtyDecimal());
if (!$this->getIsQtyDecimal()) {
$result->setHasQtyOptionUpdate(true);
$qty = intval($qty);
/**
* Adding stock data to quote item
*/
$result->setItemQty($qty);
if (!is_numeric($qty)) {
$qty = Mage::app()->getLocale()->getNumber($qty);
}
$origQty = intval($origQty);
$result->setOrigQty($origQty);
}
if ($qty < ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)) {
$result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)))->setErrorCode('qty_min')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty');
return $result;
}
if ($qty > ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)) {
$result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)))->setErrorCode('qty_max')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty');
return $result;
}
$result->addData($this->checkQtyIncrements($qty)->getData());
if ($result->getHasError()) {
return $result;
}
$option = $quoteItem->getOptionByCode('info_buyRequest');
$buyRequest = $option ? unserialize($option->getValue()) : null;
if (Mage::app()->getStore()->isAdmin() && Mage::getSingleton('adminhtml/session_quote')->getOrderId()) {
$editedOrderId = Mage::getSingleton('adminhtml/session_quote')->getOrderId();
$order = Mage::getModel('sales/order')->load($editedOrderId);
$buyRequestArray = (array) $buyRequest;
foreach ($order->getAllItems() as $oItem) {
if ($oItem->getProduct()->getId() != $product->getId()) {
continue;
}
if (is_object($oItem->getOrderItem())) {
$item = $oItem->getOrderItem();
} else {
$item = $oItem;
}
if ($item->getParentItem()) {
continue;
}
//check for bundles
if (count($item->getChildrenItems()) > 0) {
foreach ($item->getChildrenItems() as $child) {
$turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($child->getProductId(), $child);
$buyRequestArray['excluded_qty'][] = array('product_id' => $child->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered());
}
} else {
$turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($item->getProductId(), $item);
$buyRequestArray['excluded_qty'][] = array('product_id' => $item->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered());
}
}
$buyRequest = new Varien_Object($buyRequestArray);
}
if (isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) {
if (strtotime($buyRequest['start_date']) > strtotime($buyRequest['end_date'])) {
$message = Mage::helper('payperrentals')->__('Start Date is bigger then End Date. Please change!');
$result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
return $result;
}
}
$isAvailable = false;
//.........这里部分代码省略.........
示例8: processItemGroup
/**
* Adds all the items to an array including any child items.
* No need to check if item is valid. This is called after totals which already does the validation
*
* @param Array $itemGroup - The array which is passed back by reference
* @param Mage_Sales_Model_Quote_Item $item - The item to process
*/
private static function processItemGroup(&$itemGroup, $item)
{
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
$itemGroup[] = $child;
}
} else {
$itemGroup[] = $item;
}
}
示例9: _addErrorInfoForItem
/**
* Add error info to the item and quote the item belongs to with the
* provided error code and messages.
*
* @param Mage_Sales_Model_Quote_Item
* @param int
* @param string
* @param string
* @return self
*/
protected function _addErrorInfoForItem(Mage_Sales_Model_Quote_Item $item, $errorCode, $itemMessage, $quoteMessage)
{
$item->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage);
foreach ($item->getChildren() as $child) {
$child->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage);
}
$item->getQuote()->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_TYPE, EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $quoteMessage);
return $this;
}