/** * Add Weee taxes child to the XML * * @param Mage_Core_Block_Template $renderer Product renderer * @param Mage_Sales_Model_Order_Item $item * @param Mage_XmlConnect_Model_Simplexml_Element $priceXml * @param Mage_XmlConnect_Model_Simplexml_Element $subtotalXml * @param bool $isIncludeTax * @return null */ public function addPriceAndSubtotalToXml(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item, Mage_XmlConnect_Model_Simplexml_Element $priceXml, Mage_XmlConnect_Model_Simplexml_Element $subtotalXml, $isIncludeTax = false) { $weeeParams = array(); $typesOfDisplay = $renderer->getTypesOfDisplay(); if ($isIncludeTax) { $nodeName = 'including_tax'; $nodeLabel = $renderer->__('Incl. Tax'); $inclPrice = $renderer->helper('checkout')->getPriceInclTax($item); $inclSubtotal = $renderer->helper('checkout')->getSubtotalInclTax($item); if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) { $price = $inclPrice + $renderer->getWeeeTaxAppliedAmount(); $subtotal = $inclSubtotal + $item->getWeeeTaxAppliedRowAmount(); } else { $price = $inclPrice - $renderer->getWeeeTaxDisposition(); $subtotal = $inclSubtotal - $item->getWeeeTaxRowDisposition(); } $weeeParams['include'] = $inclPrice; } else { $nodeName = 'excluding_tax'; $nodeLabel = $renderer->__('Excl. Tax'); if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) { $price = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount() + $renderer->getWeeeTaxDisposition(); $subtotal = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition(); } else { $price = $item->getPrice(); $subtotal = $item->getRowTotal(); } } $configNode = array('value' => $this->formatPrice($renderer, $price)); if ($renderer->helper('tax')->displaySalesBothPrices()) { $configNode['label'] = $nodeLabel; } $this->addWeeeTaxesToPriceXml($renderer, $item, $priceXml->addCustomChild($nodeName, null, $configNode), $weeeParams); $configNode['value'] = $this->formatPrice($renderer, $subtotal); $weeeParams['include'] = $isIncludeTax ? $inclSubtotal : null; $weeeParams['is_subtotal'] = true; $this->addWeeeTaxesToPriceXml($renderer, $item, $subtotalXml->addCustomChild($nodeName, null, $configNode), $weeeParams); }
/** * Add Weee taxes child to the XML. Api version 23 * * @param Mage_Core_Block_Template $renderer Product renderer * @param Mage_Sales_Model_Order_Item $item * @param Mage_XmlConnect_Model_Simplexml_Element $priceXml * @param Mage_XmlConnect_Model_Simplexml_Element $subtotalXml * @param bool $isIncludeTax * @return null */ public function addPriceAndSubtotalToXmlApi23(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item, Mage_XmlConnect_Model_Simplexml_Element $priceXml, Mage_XmlConnect_Model_Simplexml_Element $subtotalXml, $isIncludeTax = false) { $weeeParams = array(); $typesOfDisplay = $renderer->getTypesOfDisplay(); if ($isIncludeTax) { $nodeId = self::INCLUDING_TAX_ID; $nodeLabel = $this->__('Incl. Tax'); $inclPrice = $renderer->helper('checkout')->getPriceInclTax($item); $inclSubtotal = $renderer->helper('checkout')->getSubtotalInclTax($item); if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) { $price = $inclPrice + $renderer->getWeeeTaxAppliedAmount(); $subtotal = $inclSubtotal + $item->getWeeeTaxAppliedRowAmount(); } else { $price = $inclPrice - $renderer->getWeeeTaxDisposition(); $subtotal = $inclSubtotal - $item->getWeeeTaxRowDisposition(); } $weeeParams['include'] = $inclPrice; } else { $nodeId = self::EXCLUDING_TAX_ID; $nodeLabel = $this->__('Excl. Tax'); if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) { $price = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount() + $renderer->getWeeeTaxDisposition(); $subtotal = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition(); } else { $price = $item->getPrice(); $subtotal = $item->getRowTotal(); } } $configNode = array('id' => $nodeId); $priceValue = $this->formatPrice($renderer, $price); if ($renderer->helper('tax')->displaySalesBothPrices()) { $configNode['label'] = $nodeLabel; } $priceConfig = $configNode; $idPrefix = 'price_'; $priceConfig['id'] = $idPrefix . $priceConfig['id']; $priceConfig['formatted_price'] = $priceValue; $price = Mage::helper('xmlconnect')->formatPriceForXml($price); $priceXml->addCustomChild('price', $price, $priceConfig); $this->addWeeeTaxesToPriceXmlApi23($renderer, $item, $priceXml, $weeeParams, $idPrefix, $isIncludeTax); $priceValue = $this->formatPrice($renderer, $subtotal); $weeeParams['include'] = $isIncludeTax ? $inclSubtotal : null; $weeeParams['is_subtotal'] = true; $subtotalConfig = $configNode; $idPrefix = 'subtotal_'; $subtotalConfig['id'] = $idPrefix . $subtotalConfig['id']; $subtotalConfig['formatted_price'] = $priceValue; $subtotal = Mage::helper('xmlconnect')->formatPriceForXml($subtotal); $subtotalXml->addCustomChild('price', $subtotal, $subtotalConfig); $this->addWeeeTaxesToPriceXmlApi23($renderer, $item, $subtotalXml, $weeeParams, $idPrefix, $isIncludeTax); }