本文整理汇总了PHP中Mage_Sales_Model_Quote_Item::getQuote方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item::getQuote方法的具体用法?PHP Mage_Sales_Model_Quote_Item::getQuote怎么用?PHP Mage_Sales_Model_Quote_Item::getQuote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item::getQuote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _removeErrorsFromQuoteAndItem
/**
* Removes error statuses from quote and item, set by this observer
*
* @param Mage_Sales_Model_Quote_Item $item
* @param string $origin
* @param int $code
* @return Jarlssen_CustomCartValidation_Model_Observer
*/
protected function _removeErrorsFromQuoteAndItem($item, $origin, $code)
{
if ($item->getHasError()) {
$params = array('origin' => $origin, 'code' => $code);
$item->removeErrorInfosByParams($params);
}
$quote = $item->getQuote();
$quoteItems = $quote->getItemsCollection();
$canRemoveErrorFromQuote = true;
foreach ($quoteItems as $quoteItem) {
if ($quoteItem->getItemId() == $item->getItemId()) {
continue;
}
$errorInfos = $quoteItem->getErrorInfos();
foreach ($errorInfos as $errorInfo) {
if ($errorInfo['code'] == $code) {
$canRemoveErrorFromQuote = false;
break;
}
}
if (!$canRemoveErrorFromQuote) {
break;
}
}
if ($quote->getHasError() && $canRemoveErrorFromQuote) {
$params = array('origin' => $origin, 'code' => $code);
$quote->removeErrorInfosByParams(null, $params);
}
return $this;
}
示例2: _removeErrorsFromQuoteAndItem
/**
* Removes error statuses from quote and item, set by this observer
*
* @param Mage_Sales_Model_Quote_Item $item
* @param int $code
* @return Mage_CatalogInventory_Model_Observer
*/
protected function _removeErrorsFromQuoteAndItem($item, $code)
{
//if(ITwebexperts_Payperrentals_Helper_Data::isReservationType($item->getProduct()) && ($item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE || $item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE || $item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_GROUPED)){
// return $this;
//}
if ($item->getHasError()) {
$params = array('origin' => 'cataloginventory', 'code' => $code);
$item->removeErrorInfosByParams($params);
}
$quote = $item->getQuote();
$quoteItems = $quote->getItemsCollection();
$canRemoveErrorFromQuote = true;
foreach ($quoteItems as $quoteItem) {
if ($quoteItem->getItemId() == $item->getItemId()) {
continue;
}
$errorInfos = $quoteItem->getErrorInfos();
foreach ($errorInfos as $errorInfo) {
if ($errorInfo['code'] == $code) {
$canRemoveErrorFromQuote = false;
break;
}
}
if (!$canRemoveErrorFromQuote) {
break;
}
}
if ($quote->getHasError() && $canRemoveErrorFromQuote) {
$params = array('origin' => 'cataloginventory', 'code' => $code);
$quote->removeErrorInfosByParams(null, $params);
}
return $this;
}
示例3: importQuoteItem
public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
{
$this->_quote = $quoteItem->getQuote();
$this->setQuoteItem($quoteItem)->setQuoteItemId($quoteItem->getId())->setProductId($quoteItem->getProductId())->setProduct($quoteItem->getProduct())->setSku($quoteItem->getSku())->setName($quoteItem->getName())->setDescription($quoteItem->getDescription())->setWeight($quoteItem->getWeight())->setPrice($quoteItem->getPrice())->setCost($quoteItem->getCost());
if (!$this->hasQty()) {
$this->setQty($quoteItem->getQty());
}
$this->setQuoteItemImported(true);
return $this;
}
示例4: getItemProductPrice
/**
* Fetches the item price that should be used for calculating max catalog points spending
* for the given item. Uses the following check hierarchy:
* CustomPrice
* > if not set use item price
* > if not set use product final price
* > if not set use
*
* @param Mage_Sales_Model_Quote_Item $item
*/
public function getItemProductPrice($item)
{
// Prepare data from item and initalize counters
$store_currency = (double) $this->getCurrencyRate($item->getQuote());
if ($item->hasCustomPrice()) {
$product_price = (double) $item->getCustomPrice() * $store_currency;
} elseif (Mage::helper('tax')->priceIncludesTax() && ($item->getRowTotalBeforeRedemptions() && $item->getRowTotal())) {
$rt = (double) $item->getRowTotal();
$item->setRowTotal($item->getRowTotalBeforeRedemptions());
$product_price = (double) Mage::helper('checkout')->getPriceInclTax($item);
$item->setRowTotal($rt);
} else {
// item doesn't have a price, use the item product final price
$item_price = (double) $item->getPrice();
$item_price = !empty($item_price) ? $item->getPrice() : $item->getProduct()->getFinalPrice();
$product_price = (double) $item_price * $store_currency;
}
return $product_price;
}
示例5: _addGwItemsAmount
/**
* Adds giftwrapitems cost to request as item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return int|bool
*/
protected function _addGwItemsAmount($item)
{
if (!$item->getGwId()) {
return false;
}
$lineNumber = $this->_getNewLineCode();
$storeId = $item->getQuote()->getStoreId();
//Add gift wrapping price(for individual items)
$gwItemsAmount = $item->getGwBasePrice() * $item->getQty();
$line = $this->_getNewDocumentRequestLineObject();
$line->setLineCode($lineNumber);
$gwItemsSku = $this->_getConfigHelper()->getGwItemsSku($storeId);
$line->setItemCode($gwItemsSku ? $gwItemsSku : self::DEFAULT_GW_ITEMS_SKU);
$line->setItemDescription(self::DEFAULT_GW_ITEMS_DESCRIPTION);
$line->setAvalaraGoodsAndServicesType($this->_getGiftTaxClassCode($storeId));
$line->setNumberOfItems($item->getQty());
$line->setlineAmount($gwItemsAmount);
$line->setDiscounted('false');
if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
$line->setTaxIncluded('true');
}
$this->_lines[$lineNumber] = $line;
$this->_setLinesToRequest();
$this->_lineToLineId[$lineNumber] = $this->_getConfigHelper()->getGwItemsSku($storeId);
$this->_productGiftPair[$lineNumber] = $item->getId();
return $lineNumber;
}
示例6: _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(self::ERROR_INFO_SOURCE, $errorCode, $itemMessage);
$parentItem = $item->getParentItem();
if ($parentItem) {
$parentItem->addErrorInfo(self::ERROR_INFO_SOURCE, $errorCode, $itemMessage);
}
$item->getQuote()->addErrorInfo(self::ERROR_INFO_TYPE, self::ERROR_INFO_SOURCE, $errorCode, $quoteMessage);
return $this;
}
示例7: _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);
$parentItem = $item->getParentItem();
if ($parentItem) {
$parentItem->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;
}
示例8: getQuoteItemVendor
/**
* Return vendor ID for quote item based on requested qty
*
* if $qty===true, always return dropship vendor id
* if $qty===false, always return local vendor id
* otherwise return local vendor if enough qty in stock
*
* @param Mage_Sales_Model_Quote_Item $item
* @param integer|boolean $qty
* @return integer
* @deprecated since 1.6.0
*/
public function getQuoteItemVendor($item, $qty = 0)
{
$product = $item->getProduct();
if (!$product || !$product->hasUdropshipVendor()) {
// if not available, load full product info to get product vendor
$product = Mage::getModel('catalog/product')->load($item->getProductId());
}
$store = $item->getQuote() ? $item->getQuote()->getStore() : $item->getOrder()->getStore();
$localVendorId = $this->getLocalVendorId($store);
$vendorId = $product->getUdropshipVendor();
// product doesn't have vendor specified OR force local vendor
if (!$vendorId || $qty === false) {
return $localVendorId;
}
// force real vendor
if ($qty === true) {
return $vendorId;
}
// local stock is available
if (Mage::getSingleton('udropship/stock_availability')->getUseLocalStockIfAvailable($store, $vendorId) && $product->getStockItem()->checkQty($qty)) {
return $localVendorId;
}
// all other cases
return $vendorId;
}
示例9: checkProductmaxAmount
/**
* Check max amount after adding product to cart
*
* @param Mage_Sales_Model_Quote_Item $quoteItem
*/
public function checkProductmaxAmount($quoteItem)
{
$quoteStore = $quoteItem->getStore();
if ($this->isProductEnable($quoteStore)) {
$maxAmount = $this->getCartMaxAmount($quoteStore);
/* @var $quote Mage_Sales_Model_Quote */
$quote = $quoteItem->getQuote();
$grandTotal = $quote->getGrandTotal();
$_product = Mage::getModel('catalog/product')->load($quoteItem->getProduct()->getId());
$grandTotal += $_product->getFinalPrice($quoteItem->getQty());
if ($grandTotal > $maxAmount) {
$formater = new Varien_Filter_Template();
$formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false)));
$format = $this->getProductMessage($quoteStore);
// throw exception for "remove" product to cart
Mage::throwException($formater->filter($format));
}
}
}
示例10: _addItemsInCart
/**
* Adds all items in the cart to the request
*
* @param Mage_Sales_Model_Quote_Item $item
* @return int
*/
protected function _addItemsInCart($item)
{
if ($item->getAddress() instanceof Mage_Sales_Model_Quote_Address) {
$items = $item->getAddress()->getAllItems();
} elseif ($item->getQuote() instanceof Mage_Sales_Model_Quote) {
$items = $item->getQuote()->getAllItems();
} else {
$items = array();
}
if (count($items) > 0) {
$this->_initProductCollection($items);
$this->_initTaxClassCollection($item->getAddress());
foreach ($items as $item) {
/** @var Mage_Sales_Model_Quote_Item $item */
$this->_newLine($item);
}
$this->_request->setLines($this->_lines);
}
return count($this->_lines);
}
示例11: _getTotalPercentDiscountOnitem
/**
* Returns a total discount on the cart from the provided items
*
* @param Mage_Sales_Model_Quote_Item $item
* @param Mage_Sales_Model_Quote_Address $address
* @param TBT_Rewards_Model_Sales_Rule $rule
* @param array() &$cartRules
* @param int $qty max discount qty or unlimited if null
* @return array($discountAmount, $baseDiscountAmount)
*/
protected function _getTotalPercentDiscountOnitem($item, $address, $rule, &$cartRules, $qty = null)
{
$quote = $item->getQuote();
$store = $item->getQuote()->getStore();
$rulePercent = $this->_getRulePercent($rule);
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
$quoteAmountBase = $cartRules[$rule->getId()];
list($item_row_total, $item_base_row_total) = $this->_getDiscountableRowTotal($address, $item, $rule);
$discountAmount = $item_row_total * $rulePercent;
$baseDiscountAmount = $item_base_row_total * $rulePercent;
return array($discountAmount, $baseDiscountAmount);
}
示例12: _getTotalFixedDiscountOnitem
/**
* Returns a total discount on the cart from the provided items
* @deprecated @see TBT_Rewards_Model_Salesrule_Discount_Action_Cartfixed
*
* @param Mage_Sales_Model_Quote_Item $item
* @param Mage_Sales_Model_Quote_Address $address
* @param TBT_Rewards_Model_Sales_Rule $rule
* @param array() &$cartRules
* @return array($discountAmount, $baseDiscountAmount)
*/
protected function _getTotalFixedDiscountOnitem($item, $address, $rule, &$cartRules)
{
$quote = $item->getQuote();
$store = $item->getQuote()->getStore();
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
if ($rule->getPointsAction() == TBT_Rewards_Model_Salesrule_Actions::ACTION_DISCOUNT_BY_POINTS_SPENT) {
$points_spent = Mage::getSingleton('rewards/session')->getPointsSpending();
$multiplier = floor($points_spent / $rule->getPointsAmount());
} else {
$multiplier = 1;
}
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
if (Mage::helper('tax')->discountTax($store) && !Mage::helper('tax')->applyTaxAfterDiscount($store)) {
$tax_amount = $item->getTaxAmount();
$base_tax_amount = $item->getBaseTaxAmount();
} else {
$tax_amount = 0;
$base_tax_amount = 0;
}
if (Mage::helper('rewards')->isBaseMageVersionAtLeast('1.4.2')) {
$itemPrice = $this->_getItemPrice($item);
$baseItemPrice = $this->_getItemBasePrice($item);
$qty = $this->_getItemQty($item, $rule);
if (1 >= $this->_rulesItemTotals[$rule->getId()]['items_count']) {
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
$discountAmount = min($itemPrice * $qty, $quoteAmount);
$baseDiscountAmount = min($baseItemPrice * $qty, $cartRules[$rule->getId()]);
} else {
$discountRate = $baseItemPrice * $qty / $this->_rulesItemTotals[$rule->getId()]['base_items_price'];
$maximumItemDiscount = $rule->getDiscountAmount() * $discountRate;
$quoteAmount = $quote->getStore()->convertPrice($maximumItemDiscount);
$discountAmount = min($itemPrice * $qty, $quoteAmount);
$baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount);
$this->_rulesItemTotals[$rule->getId()]['items_count']--;
}
} else {
$discountAmount = min($item->getRowTotal() - $item->getDiscountAmount() + $tax_amount, $quoteAmount);
$baseDiscountAmount = min($item->getBaseRowTotal() - $item->getBaseDiscountAmount() + $base_tax_amount, $cartRules[$rule->getId()]);
}
return array($discountAmount, $baseDiscountAmount);
}
示例13: getUpdatedRedemptionData
/**
* Retenders the item's redemption rules and final row total and returns it.
* @param Mage_Sales_Model_Quote_Item $item
* @return array a map of the new item redemption data:
* array('redemptions_data'=>{...}, 'row_total'=>float)
*/
protected function getUpdatedRedemptionData($item, $do_incl_tax = true)
{
// Step 1: Create a map of usability for all applied redemptions
//echo "$item->getRedeemedPointsHash()";
$redeemed_points = Mage::helper('rewards')->unhashIt($item->getRedeemedPointsHash());
// Prepare data from item and initalize counters
if ($item->getQuote()) {
$store_currency = round($item->getQuote()->getStoreToQuoteRate(), 4);
}
if ($item->getOrder()) {
$store_currency = round($item->getOrder()->getStoreToQuoteRate(), 4);
}
if ($item->hasCustomPrice()) {
$product_price = (double) $item->getCustomPrice() * $store_currency;
} else {
//@nelkaake -a 17/02/11: We need to use our own calculation because the one that was set by the
// rest of the Magento system is rounded.
if (Mage::helper('tax')->priceIncludesTax() && $item->getPriceInclTax()) {
$product_price = $item->getPriceInclTax() / (1 + $item->getTaxPercent() / 100);
} else {
$product_price = (double) $item->getPrice() * $store_currency;
}
}
if ($item->getParentItem() || sizeof($redeemed_points) == 0) {
return array('redemptions_data' => array(), 'row_total_incl_tax' => $item->getRowTotalInclTax(), 'row_total' => $item->getRowTotal());
}
$total_qty = $item->getQty();
$total_qty_redeemed = 0.0;
$row_total = 0.0;
$new_redeemed_points = array();
$ret = array();
// Loop through and apply all our rules.
foreach ($redeemed_points as $key => &$redemption_instance) {
$redemption_instance = (array) $redemption_instance;
$applic_qty = $redemption_instance[self::POINTS_APPLICABLE_QTY];
$rule_id = $redemption_instance[self::POINTS_RULE_ID];
$effect = $redemption_instance[self::POINTS_EFFECT];
$uses = isset($redemption_instance[self::POINTS_USES]) ? (int) $redemption_instance[self::POINTS_USES] : 1;
$rule = Mage::helper('rewards/rule')->getCatalogRule($rule_id);
// If a rule was turned off at some point in the back-end it should be removed and not calculated in the cart anymore.
if (!$rule->getIsActive()) {
$this->removeCatalogRedemptionsFromItem($item, array($rule_id));
$effect = "";
}
$total_qty_remain = $total_qty - $total_qty_redeemed;
if ($total_qty_remain > 0) {
if ($total_qty_remain < $applic_qty) {
$applic_qty = $total_qty_remain;
$redemption_instance[TBT_Rewards_Model_Redeem::POINTS_APPLICABLE_QTY] = $applic_qty;
}
$price_after_redem = $this->getPriceAfterEffect($product_price, $effect, $item);
$row_total += $applic_qty * (double) $price_after_redem;
$total_qty_redeemed += $applic_qty;
$new_redeemed_points[] = $redemption_instance;
} else {
$redemption_instance[TBT_Rewards_Model_Catalogrule_Rule::POINTS_APPLICABLE_QTY] = 0;
$redemption_instance[TBT_Rewards_Model_Catalogrule_Rule::POINTS_USES] = 1;
// used once by default
unset($redeemed_points[$key]);
}
}
$ret['redemptions_data'] = $new_redeemed_points;
// Add in the left over products that perhaps weren't affected by qty adjustment.
$total_qty_remain = $total_qty - $total_qty_redeemed;
if ($total_qty_remain < 0) {
$total_qty_remain = 0;
$total_qty_redeemed = $total_qty;
//throw new Exception("Redemption rules may be overlapping. Please notify the store administrator of this error.");
}
$row_total += $total_qty_remain * (double) $product_price;
$ret['row_total'] = $row_total;
$ret['row_total_incl_tax'] = $row_total * (1 + $item->getTaxPercent() / 100);
return $ret;
}
示例14: _getTotalFixedDiscountOnitem
/**
* Returns a total discount on the cart from the provided items
*
* @param Mage_Sales_Model_Quote_Item $item
* @param Mage_Sales_Model_Quote_Address $address
* @param TBT_Rewards_Model_Sales_Rule $rule
* @param array() &$cartRules
* @return array($discountAmount, $baseDiscountAmount)
*/
protected function _getTotalFixedDiscountOnitem($item, $address, $rule, &$cartRules)
{
$quote = $item->getQuote();
$store = $item->getQuote()->getStore();
if ($rule->getPointsAction() == TBT_Rewards_Model_Salesrule_Actions::ACTION_DISCOUNT_BY_POINTS_SPENT) {
$points_spent = Mage::getSingleton('rewards/session')->getPointsSpending();
$multiplier = floor($points_spent / $rule->getPointsAmount());
} else {
$multiplier = 1;
}
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
list($item_row_total, $item_base_row_total) = $this->_getDiscountableRowTotal($address, $item, $rule);
$discountAmount = min($item_row_total, $quoteAmount);
$baseDiscountAmount = min($item_base_row_total, $cartRules[$rule->getId()]);
return array($discountAmount, $baseDiscountAmount);
}
示例15: _removeErrorsFromQuoteAndItem
/**
* Removes error statuses from quote and item, set by this observer
*
* @param Mage_Sales_Model_Quote_Item $item
* @param int $code
* @return Mage_CatalogInventory_Model_Observer
*/
protected function _removeErrorsFromQuoteAndItem($item, $code)
{
if ($item->getHasError()) {
$params = array('origin' => 'cataloginventory', 'code' => $code);
$item->removeErrorInfosByParams($params);
}
$quote = $item->getQuote();
if ($quote->getHasError()) {
$params = array('origin' => 'cataloginventory', 'code' => $code);
$quote->removeErrorInfosByParams(null, $params);
}
return $this;
}