本文整理汇总了PHP中Mage_Sales_Model_Quote_Item_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item_Abstract类的具体用法?PHP Mage_Sales_Model_Quote_Item_Abstract怎么用?PHP Mage_Sales_Model_Quote_Item_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Sales_Model_Quote_Item_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEddMessage
/**
* Get an estimated delivery message for a quote item.
*
* @param Mage_Sales_Model_Quote_Item_Abstract
* @return string
*/
public function getEddMessage(Mage_Sales_Model_Quote_Item_Abstract $item)
{
/** @var string $singularOrPluralItem */
$singularOrPluralItem = (int) $item->getQty() > 1 ? 's' : '';
/** @var EbayEnterprise_Inventory_Model_Details_Item | Varien_Object | null $eddItem */
$eddItem = $this->detailService->getDetailsForItem($item) ?: $this->inventoryHelper->getStreetDateForBackorderableItem($item);
return $eddItem ? $this->inventoryHelper->__($this->getEddTemplate(), $singularOrPluralItem, $eddItem->getDeliveryWindowFromDate()->format('m/d/y'), $eddItem->getDeliveryWindowToDate()->format('m/d/y')) : '';
}
示例2: _calcUnitTaxAmount
/**
* Calculate tax for each product
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param type $rate
* @return Magestore_Customerreward_Model_Total_Quote_Tax
*/
protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate)
{
$discount = $item->getDiscountAmount();
$baseDiscount = $item->getBaseDiscountAmount();
$item->setDiscountAmount($discount + $item->getAffiliateplusAmount() + $item->getCustomerrewardAmount());
$item->setBaseDiscountAmount($baseDiscount + $item->getBaseAffiliateplusAmount() + $item->getBaseCustomerrewardAmount());
parent::_calcUnitTaxAmount($item, $rate);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
return $this;
}
示例3: _calcUnitTaxAmount
/**
* Calculate tax for each product
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param type $rate
* @return Magestore_Customerreward_Model_Total_Quote_Tax
*/
protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate, &$taxGroups = null, $taxId = null, $recalculateRowTotalInclTax = false)
{
$discount = $item->getDiscountAmount();
$baseDiscount = $item->getBaseDiscountAmount();
/* hainh add this for calculating discount base on incl or excl tax price 22-04-2014 */
if (!$this->_discountIncludeTax()) {
$item->setDiscountAmount($discount + $item->getAffiliateplusAmount() + $item->getCustomerrewardAmount());
$item->setBaseDiscountAmount($baseDiscount + $item->getBaseAffiliateplusAmount() + $item->getBaseCustomerrewardAmount());
}
parent::_calcUnitTaxAmount($item, $rate, $taxGroups, $taxId, $recalculateRowTotalInclTax);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
return $this;
}
示例4: addItemDiscountPrices
/**
* Add additional amounts to discount calculation prices
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param float $basePrice
* @param float $price
* @return Mage_SalesRule_Helper_Data
*/
public function addItemDiscountPrices(Mage_Sales_Model_Quote_Item_Abstract $item, $basePrice, $price)
{
$discountPrice = $item->getDiscountCalculationPrice();
$baseDiscountPrice = $item->getBaseDiscountCalculationPrice();
if ($discountPrice || $baseDiscountPrice || $basePrice || $price) {
$discountPrice = $discountPrice ? $discountPrice : $item->getCalculationPrice();
$baseDiscountPrice = $baseDiscountPrice ? $baseDiscountPrice : $item->getBaseCalculationPrice();
$this->setItemDiscountPrices($item, $baseDiscountPrice + $basePrice, $discountPrice + $price);
}
return $this;
}
示例5: process
public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
$item->setDiscountPercent(0);
$quote = $item->getQuote();
$address = $this->_getAddress($item);
$qty = $item->getTotalQty();
$itemPrice = $this->_getItemPrice($item);
$baseItemPrice = $this->_getItemBasePrice($item);
$itemOriginalPrice = $this->_getItemOriginalPrice($item);
$baseItemOriginalPrice = $this->_getItemBaseOriginalPrice($item);
if ($itemPrice < 0) {
return $this;
}
if ($this->_totaldiscountpay > 0) {
if ($this->_rulesItemTotalspay['giftcardpay']['items_count'] <= 1) {
$quoteAmount = $quote->getStore()->convertPrice($this->_totaldiscountpay);
$baseDiscountAmount = min($baseItemPrice * $qty, $this->_totaldiscountpay);
} else {
$discountRate = $baseItemPrice * $qty / $this->_rulesItemTotalspay['giftcardpay']['base_items_price'];
$maximumItemDiscount = $this->_totaldiscountpay * $discountRate;
$quoteAmount = $quote->getStore()->convertPrice($maximumItemDiscount);
$baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount);
$this->_rulesItemTotalspay['giftcardpay']['items_count']--;
}
$discountAmount = min($itemPrice * $qty, $quoteAmount);
$discountAmount = $quote->getStore()->roundPrice($discountAmount);
$baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
//get discount for original price
$originalDiscountAmount = min($itemOriginalPrice * $qty, $quoteAmount);
$baseOriginalDiscountAmount = $quote->getStore()->roundPrice($baseItemOriginalPrice);
$this->_totaldiscountpay -= $baseDiscountAmount;
}
$itemDiscountAmount = $item->getDiscountAmount();
$itemBaseDiscountAmount = $item->getBaseDiscountAmount();
$discountAmount = min($itemDiscountAmount + $discountAmount, $itemPrice * $qty);
$baseDiscountAmount = min($itemBaseDiscountAmount + $baseDiscountAmount, $baseItemPrice * $qty);
$item->getGiftCardEarn($discountAmount);
$item->getGiftCardBaseEarn($discountAmount);
$baseTaxableAmount = $item->getBaseTaxableAmount();
$taxableAmount = $item->getTaxableAmount();
$item->setBaseTaxableAmount(max(0, $baseTaxableAmount - $discountAmount));
$item->setTaxableAmount(max(0, $taxableAmount - $discountAmount));
return $this;
}
示例6: _getItemQty
/**
* Return discount item qty
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param Mage_SalesRule_Model_Rule $rule
* @return int
*/
protected function _getItemQty($item, $rule)
{
$qty = $item->getTotalQty();
return $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty;
}
示例7: getTotalItemDetails
/**
* Getter for nominal total item details
*
* @param Mage_Sales_Model_Quote_Item_Abstract $quoteItem
* @return array
*/
public function getTotalItemDetails(Mage_Sales_Model_Quote_Item_Abstract $quoteItem)
{
return $quoteItem->getNominalTotalDetails();
}
示例8: getAddress_new
protected function getAddress_new(Mage_Sales_Model_Quote_Item_Abstract $item)
{
if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
$address = $item->getAddress();
} elseif ($item->getQuote()->isVirtual()) {
$address = $item->getQuote()->getBillingAddress();
} else {
$address = $item->getQuote()->getShippingAddress();
}
return $address;
}
示例9: itemToOrderItem
/**
* Convert quote item to order item
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return Mage_Sales_Model_Order_Item
*/
public function itemToOrderItem(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$orderItem = Mage::getModel('Mage_Sales_Model_Order_Item')->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setQuoteParentItemId($item->getParentItemId())->setProductId($item->getProductId())->setProductType($item->getProductType())->setQtyBackordered($item->getBackorders())->setProduct($item->getProduct())->setBaseOriginalPrice($item->getBaseOriginalPrice());
$options = $item->getProductOrderOptions();
if (!$options) {
$options = $item->getProduct()->getTypeInstance()->getOrderOptions($item->getProduct());
}
$orderItem->setProductOptions($options);
Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_quote_item', 'to_order_item', $item, $orderItem);
if ($item->getParentItem()) {
$orderItem->setQtyOrdered($orderItem->getQtyOrdered() * $item->getParentItem()->getQty());
}
if (!$item->getNoDiscount()) {
Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_quote_item', 'to_order_item_discount', $item, $orderItem);
}
Mage::dispatchEvent('sales_convert_quote_item_to_order_item', array('order_item' => $orderItem, 'item' => $item));
return $orderItem;
}
示例10: isItemGiftWrapped
/**
* return true if the item is giftwrapped; false otherwise.
*
* @param Mage_Sales_Model_Quote_Item_Abstract
* @return bool
*/
protected function isItemGiftWrapped(Mage_Sales_Model_Quote_Item_Abstract $item)
{
return (bool) $item->getGwId() || $item->getAddress() && $item->getAddress()->getGwId();
}
示例11: requestShippingRates
/**
* Request shipping rates for entire address or specified address item
* Returns true if current selected shipping method code corresponds to one of the found rates
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return bool
*/
public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
{
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setAllItems($item ? array($item) : $this->getAllItems());
$request->setDestCountryId($this->getCountryId());
$request->setDestRegionId($this->getRegionId());
$request->setDestRegionCode($this->getRegionCode());
/**
* need to call getStreet with -1
* to get data in string instead of array
*/
$request->setDestStreet($this->getStreet(-1));
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$request->setPackageValueWithDiscount($packageValueWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);
$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
/**
* Store and website identifiers need specify from quote
*/
/*$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
$request->setStoreId($this->getQuote()->getStore()->getId());
$request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
$request->setFreeShipping($this->getFreeShipping());
/**
* Currencies need to convert in free shipping
*/
$request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
$request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($this->getLimitCarrier());
$request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax());
$result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
$found = false;
if ($result) {
$shippingRates = $result->getAllRates();
// ============ Apply shipping on order minimum value after discount specific to coupon code only =================
if (!Mage::app()->getStore()->isAdmin()) {
foreach ($shippingRates as $i => $r) {
if ($r->getMethod() == 'freeshipping') {
unset($shippingRates[$i]);
}
}
}
$isfree = true;
$minimum_purchange_amount = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount');
$minimum_purchange_amount_status = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount_status');
if ($minimum_purchange_amount_status == '1' && $minimum_purchange_amount > 0) {
$minPurchaseAmt = Mage::helper('common')->checkMinPurchageAmount($minimum_purchange_amount);
if ($minPurchaseAmt) {
foreach ($shippingRates as $i => $r) {
if ($r->getMethod() == 'standard') {
$shippingRates[$i]->setPrice(0);
$shippingRates[$i]->setCost(0);
$isfree = true;
}
}
}
}
// ==========================================================================================
foreach ($shippingRates as $shippingRate) {
$rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
if (!$item) {
$this->addShippingRate($rate);
}
if ($this->getShippingMethod() == $rate->getCode()) {
if ($item) {
$item->setBaseShippingAmount($rate->getPrice());
} else {
/**
* possible bug: this should be setBaseShippingAmount(),
* see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
* where this value is set again from the current specified rate price
* (looks like a workaround for this bug)
*/
$this->setShippingAmount($rate->getPrice());
}
$found = true;
}
}
}
return $found;
}
示例12: process
public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$item->setFreeShipping(false);
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
$item->setDiscountPercent(0);
$quote = $item->getQuote();
$address = $item->getAddress();
if (!$address) {
$address = $item->getQuote()->getShippingAddress();
}
$customerId = $quote->getCustomerId();
$ruleCustomer = Mage::getModel('salesrule/rule_customer');
$appliedRuleIds = array();
foreach ($this->_rules as $rule) {
/**
* already tried to validate and failed
*/
if ($rule->getIsValid() === false) {
continue;
}
if ($rule->getIsValid() !== true) {
/**
* too many times used in general
*/
if ($rule->getUsesPerCoupon() && $rule->getTimesUsed() >= $rule->getUsesPerCoupon()) {
$rule->setIsValid(false);
continue;
}
/**
* too many times used for this customer
*/
if ($ruleId = $rule->getId()) {
$ruleCustomer->loadByCustomerRule($customerId, $ruleId);
if ($ruleCustomer->getId()) {
if ($ruleCustomer->getTimesUsed() >= $rule->getUsesPerCustomer()) {
continue;
}
}
}
$rule->afterLoad();
/**
* quote does not meet rule's conditions
*/
if (!$rule->validate($address)) {
$rule->setIsValid(false);
continue;
}
/**
* passed all validations, remember to be valid
*/
$rule->setIsValid(true);
}
/**
* although the rule is valid, this item is not marked for action
*/
if (!$rule->getActions()->validate($item)) {
continue;
}
$qty = $rule->getDiscountQty() ? min($item->getQty(), $rule->getDiscountQty()) : $item->getQty();
$rulePercent = $rule->getDiscountAmount();
switch ($rule->getSimpleAction()) {
case 'to_percent':
$rulePercent = max(0, 100 - $rule->getDiscountAmount());
//no break;
//no break;
case 'by_percent':
$discountAmount = $qty * $item->getCalculationPrice() * $rulePercent / 100;
$baseDiscountAmount = $qty * $item->getBaseCalculationPrice() * $rulePercent / 100;
if (!$rule->getDiscountQty()) {
$discountPercent = min(100, $item->getDiscountPercent() + $rulePercent);
$item->setDiscountPercent($discountPercent);
}
break;
case 'to_fixed':
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
$discountAmount = $qty * ($item->getCalculationPrice() - $quoteAmount);
$baseDiscountAmount = $qty * ($item->getBaseCalculationPrice() - $rule->getDiscountAmount());
break;
case 'by_fixed':
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
$discountAmount = $qty * $quoteAmount;
$baseDiscountAmount = $qty * $rule->getDiscountAmount();
break;
}
$discountAmount = $quote->getStore()->roundPrice($discountAmount);
$baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
$discountAmount = min($discountAmount, $item->getRowTotal());
$baseDiscountAmount = min($baseDiscountAmount, $item->getBaseRowTotal());
$item->setDiscountAmount($discountAmount);
$item->setBaseDiscountAmount($baseDiscountAmount);
switch ($rule->getSimpleFreeShipping()) {
case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM:
$item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true);
break;
case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ADDRESS:
$address->setFreeShipping(true);
break;
}
$appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
//.........这里部分代码省略.........
示例13: _recalculateParent
/**
* Recalculate parent item amounts base on children data
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return Mage_Tax_Model_Sales_Total_Quote
*/
protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$rowTaxAmount = 0;
$baseRowTaxAmount = 0;
foreach ($item->getChildren() as $child) {
$rowTaxAmount += $child->getTaxAmount();
$baseRowTaxAmount += $child->getBaseTaxAmount();
}
$item->setTaxAmount($rowTaxAmount);
$item->setBaseTaxAmount($baseRowTaxAmount);
return $this;
}
示例14: resetItem
protected function resetItem(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$item->setDiscountAmount(0.0);
$item->setBaseDiscountAmount(0.0);
$item->setRowTotalWithDiscount($item->getRowTotal());
$item->setBaseRowTotalWithDiscount($item->getBaseRowTotal());
$item->setDiscountPercent(0);
$item->setAppliedRuleIds('');
$item->setFreeShipping(false);
}
示例15: getStoreRateForItem
/**
* Get tax rate based on store shipping origin address settings
* This rate can be used for conversion store price including tax to
* store price excluding tax
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param null|Mage_Core_Model_Store $store
* @return float
*/
public function getStoreRateForItem($item, $store = null)
{
$storeRequest = $this->getRateOriginRequest($store)->setProductClassId($item->getProduct()->getTaxClassId());
return $this->getRate($storeRequest);
}