本文整理汇总了PHP中Mage_Sales_Model_Quote_Item_Abstract::getBaseCalculationPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item_Abstract::getBaseCalculationPrice方法的具体用法?PHP Mage_Sales_Model_Quote_Item_Abstract::getBaseCalculationPrice怎么用?PHP Mage_Sales_Model_Quote_Item_Abstract::getBaseCalculationPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item_Abstract
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item_Abstract::getBaseCalculationPrice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: _getItemBasePrice
/**
* Return item base price
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return float
*/
protected function _getItemBasePrice($item)
{
$price = $item->getDiscountCalculationPrice();
return $price !== null ? $item->getBaseDiscountCalculationPrice() : $item->getBaseCalculationPrice();
}
示例3: _calcUnitTaxAmount
/**
* Calculate unit tax anount based on unit price
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param float $rate
* @return Mage_Tax_Model_Sales_Total_Quote
*/
protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate)
{
$store = $item->getStore();
$inclTax = $this->_usePriceIncludeTax($store);
$extra = $item->getExtraTaxableAmount();
$baseExtra = $item->getBaseExtraTaxableAmount();
if ($inclTax) {
$price = $store->roundPrice($item->getTaxCalcPrice()) + $extra;
$basePrice = $store->roundPrice($item->getBaseTaxCalcPrice()) + $baseExtra;
} else {
if ($item->hasCustomPrice() && $this->_helper->applyTaxOnCustomPrice($store)) {
$price = $store->roundPrice($item->getCalculationPrice()) + $extra;
$basePrice = $store->roundPrice($item->getBaseCalculationPrice()) + $baseExtra;
} else {
$price = $store->roundPrice($item->getOriginalPrice()) + $item->getExtraTaxableAmount();
$basePrice = $store->roundPrice($item->getBaseOriginalPrice()) + $item->getBaseExtraTaxableAmount();
}
}
$discountAmount = $item->getDiscountAmount();
$baseDiscountAmount = $item->getBaseDiscountAmount();
$qty = $item->getTotalQty();
$item->setTaxPercent($rate);
$rate = $rate / 100;
$calculationSequence = $this->_config->getCalculationSequence($store);
switch ($calculationSequence) {
case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL:
$unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
$baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
break;
case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL:
$unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
$baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
if ($inclTax) {
$item->setDiscountCalculationPrice($price);
$item->setBaseDiscountCalculationPrice($basePrice);
} else {
$item->setDiscountCalculationPrice($price + $unitTax);
$item->setBaseDiscountCalculationPrice($basePrice + $baseUnitTax);
}
break;
case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
$unitTax = $this->_calculator->calcTaxAmount($price - $discountAmount / $qty, $rate, $inclTax);
$baseUnitTax = $this->_calculator->calcTaxAmount($basePrice - $baseDiscountAmount / $qty, $rate, $inclTax);
break;
}
$totalTax = $store->roundPrice($qty * $unitTax);
$totalBaseTax = $store->roundPrice($qty * $baseUnitTax);
/**
* Renew item amounts in case if we are working with price include tax
*/
if ($inclTax) {
if ($item->hasCustomPrice()) {
$item->setCustomPrice($item->getPriceInclTax() - $unitTax);
$item->setBaseCustomPrice($item->getBasePriceInclTax() - $baseUnitTax);
} else {
$item->setOriginalPrice($item->getPriceInclTax() - $unitTax);
$item->setPrice($item->getBasePriceInclTax() - $baseUnitTax);
$item->setBasePrice($item->getBasePriceInclTax() - $baseUnitTax);
}
$item->setRowTotal($item->getRowTotalInclTax() - $totalTax);
$item->setBaseRowTotal($item->getBaseRowTotalInclTax() - $totalBaseTax);
}
$item->setTaxAmount($totalTax);
$item->setBaseTaxAmount($totalBaseTax);
return $this;
}
示例4: getItemBasePrice
/**
* Return item base price
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
*
* @return float
*/
public function getItemBasePrice(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$price = $item->getDiscountCalculationPrice();
return $price !== null ? $item->getBaseDiscountCalculationPrice() : $item->getBaseCalculationPrice();
}
示例5: _recollectItem
/**
* Recollect item price and row total using after taxes subtract.
* Declare item price including tax attributes
* @deprecated after 1.4.1
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return Mage_Tax_Model_Sales_Total_Quote_Subtotal
*/
protected function _recollectItem($address, Mage_Sales_Model_Quote_Item_Abstract $item)
{
$store = $address->getQuote()->getStore();
$request = $this->_getStoreTaxRequest($address);
$request->setProductClassId($item->getProduct()->getTaxClassId());
$rate = $this->_calculator->getRate($request);
$qty = $item->getTotalQty();
$price = $taxPrice = $item->getCalculationPrice();
$basePrice = $baseTaxPrice = $item->getBaseCalculationPrice();
$subtotal = $taxSubtotal = $item->getRowTotal();
$baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal();
if ($this->_config->discountTax($store)) {
$item->setDiscountCalculationPrice($price);
$item->setBaseDiscountCalculationPrice($basePrice);
}
/**
* Use original price for tax calculation
*/
if ($item->hasCustomPrice() && !$this->_helper->applyTaxOnCustomPrice($store)) {
$taxPrice = $item->getOriginalPrice();
$baseTaxPrice = $item->getBaseOriginalPrice();
$taxSubtotal = $taxPrice * $qty;
$baseTaxSubtotal = $baseTaxPrice * $qty;
}
if ($this->_areTaxRequestsSimilar) {
$item->setRowTotalInclTax($subtotal);
$item->setBaseRowTotalInclTax($baseSubtotal);
$item->setPriceInclTax($price);
$item->setBasePriceInclTax($basePrice);
$item->setTaxCalcPrice($taxPrice);
$item->setBaseTaxCalcPrice($baseTaxPrice);
$item->setTaxCalcRowTotal($taxSubtotal);
$item->setBaseTaxCalcRowTotal($baseTaxSubtotal);
}
$this->_subtotalInclTax += $subtotal;
$this->_baseSubtotalInclTax += $baseSubtotal;
if ($this->_config->getAlgorithm($store) == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
$taxAmount = $this->_calculator->calcTaxAmount($taxPrice, $rate, true);
$baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxPrice, $rate, true);
$unitPrice = $this->_calculator->round($price - $taxAmount);
$baseUnitPrice = $this->_calculator->round($basePrice - $baseTaxAmount);
$subtotal = $this->_calculator->round($unitPrice * $qty);
$baseSubtotal = $this->_calculator->round($baseUnitPrice * $qty);
} else {
$taxAmount = $this->_calculator->calcTaxAmount($taxSubtotal, $rate, true, false);
$baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxSubtotal, $rate, true, false);
$unitPrice = ($subtotal - $taxAmount) / $qty;
$baseUnitPrice = ($baseSubtotal - $baseTaxAmount) / $qty;
$subtotal = $this->_calculator->round($subtotal - $taxAmount);
$baseSubtotal = $this->_calculator->round($baseSubtotal - $baseTaxAmount);
}
if ($item->hasCustomPrice()) {
$item->setCustomPrice($unitPrice);
$item->setBaseCustomPrice($baseUnitPrice);
}
$item->setPrice($baseUnitPrice);
$item->setOriginalPrice($unitPrice);
$item->setBasePrice($baseUnitPrice);
$item->setRowTotal($subtotal);
$item->setBaseRowTotal($baseSubtotal);
return $this;
}
示例6: 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('sales/order_item')->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setSuperProductId($item->getSuperProductId())->setParentProductId($item->getParentProductId())->setSku($item->getSku())->setName($item->getName())->setDescription($item->getDescription())->setWeight($item->getWeight())->setIsQtyDecimal($item->getIsQtyDecimal())->setQtyOrdered($item->getQty())->setOriginalPrice($item->getOriginalPrice())->setAppliedRuleIds($item->getAppliedRuleIds())->setAdditionalData($item->getAdditionalData())->setPrice($item->getCalculationPrice())->setTaxPercent($item->getTaxPercent())->setTaxAmount($item->getTaxAmount())->setRowWeight($item->getRowWeight())->setRowTotal($item->getRowTotal())->setBasePrice($item->getBaseCalculationPrice())->setBaseOriginalPrice($item->getPrice())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotal($item->getBaseRowTotal());
if (!$item->getNoDiscount()) {
$orderItem->setDiscountPercent($item->getDiscountPercent())->setDiscountAmount($item->getDiscountAmount())->setBaseDiscountAmount($item->getBaseDiscountAmount());
}
Mage::dispatchEvent('sales_convert_quote_item_to_order_item', array('order_item' => $orderItem, 'item' => $item));
return $orderItem;
}