1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Block_Onepage_Review_Info
35: {
36: 37: 38: 39: 40:
41: protected function _toHtml()
42: {
43: $itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<products></products>');
44: $quote = Mage::getSingleton('checkout/session')->getQuote();
45:
46:
47: foreach ($this->getItems() as $item) {
48: $type = $this->_getItemType($item);
49: $renderer = $this->getItemRenderer($type)->setItem($item);
50:
51: 52: 53:
54: $itemXml = $itemsXmlObj->addChild('item');
55: $itemXml->addChild('entity_id', $item->getProduct()->getId());
56: $itemXml->addChild('entity_type', $type);
57: $itemXml->addChild('item_id', $item->getId());
58: $itemXml->addChild('name', $itemsXmlObj->escapeXml($renderer->getProductName()));
59: $itemXml->addChild('qty', $renderer->getQty());
60: $icon = $renderer->getProductThumbnail()->resize(
61: Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')
62: );
63:
64: $iconXml = $itemXml->addChild('icon', $icon);
65:
66: $file = Mage::helper('xmlconnect')->urlToPath($icon);
67: $iconXml->addAttribute('modification_time', filemtime($file));
68:
69: 70: 71:
72: $exclPrice = $inclPrice = 0.00;
73: if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
74: $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
75: if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
76: $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
77: + $item->getWeeeTaxDisposition();
78: } else {
79: $exclPrice = $item->getCalculationPrice();
80: }
81: }
82:
83: if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
84: $_incl = $this->helper('checkout')->getPriceInclTax($item);
85: $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
86: if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
87: $inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
88: } else {
89: $inclPrice = $_incl - $item->getWeeeTaxDisposition();
90: }
91: }
92:
93: $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
94: $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
95:
96: $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
97: $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
98:
99: $priceXmlObj = $itemXml->addChild('price');
100: $formattedPriceXmlObj = $itemXml->addChild('formated_price');
101:
102: if ($this->helper('tax')->displayCartBothPrices()) {
103: $priceXmlObj->addAttribute('excluding_tax', $exclPrice);
104: $priceXmlObj->addAttribute('including_tax', $inclPrice);
105:
106: $formattedPriceXmlObj->addAttribute('excluding_tax', $formattedExclPrice);
107: $formattedPriceXmlObj->addAttribute('including_tax', $formattedInclPrice);
108: } else {
109: if ($this->helper('tax')->displayCartPriceExclTax()) {
110: $priceXmlObj->addAttribute('regular', $exclPrice);
111: $formattedPriceXmlObj->addAttribute('regular', $formattedExclPrice);
112: }
113: if ($this->helper('tax')->displayCartPriceInclTax()) {
114: $priceXmlObj->addAttribute('regular', $inclPrice);
115: $formattedPriceXmlObj->addAttribute('regular', $formattedInclPrice);
116: }
117: }
118:
119: 120: 121:
122: $exclPrice = $inclPrice = 0.00;
123: if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
124: $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
125: if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
126: $exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
127: + $item->getWeeeTaxRowDisposition();
128: } else {
129: $exclPrice = $item->getRowTotal();
130: }
131: }
132: if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
133: $_incl = $this->helper('checkout')->getSubtotalInclTax($item);
134: if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
135: && $item->getWeeeTaxAppliedAmount()
136: ) {
137: $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount();
138: } else {
139: $inclPrice = $_incl - $item->getWeeeTaxRowDisposition();
140: }
141: }
142:
143: $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
144: $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
145:
146: $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
147: $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
148:
149: $subtotalPriceXmlObj = $itemXml->addChild('subtotal');
150: $subtotalFormattedPriceXmlObj = $itemXml->addChild('formated_subtotal');
151:
152: if ($this->helper('tax')->displayCartBothPrices()) {
153: $subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice);
154: $subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice);
155:
156: $subtotalFormattedPriceXmlObj->addAttribute('excluding_tax', $formattedExclPrice);
157: $subtotalFormattedPriceXmlObj->addAttribute('including_tax', $formattedInclPrice);
158: } else {
159: if ($this->helper('tax')->displayCartPriceExclTax()) {
160: $subtotalPriceXmlObj->addAttribute('regular', $exclPrice);
161: $subtotalFormattedPriceXmlObj->addAttribute('regular', $formattedExclPrice);
162: }
163: if ($this->helper('tax')->displayCartPriceInclTax()) {
164: $subtotalPriceXmlObj->addAttribute('regular', $inclPrice);
165: $subtotalFormattedPriceXmlObj->addAttribute('regular', $formattedInclPrice);
166: }
167: }
168:
169: 170: 171:
172: $_options = $renderer->getOptionList();
173: if ($_options) {
174: $itemOptionsXml = $itemXml->addChild('options');
175: foreach ($_options as $_option) {
176: $_formattedOptionValue = $renderer->getFormatedOptionValue($_option);
177: $optionXml = $itemOptionsXml->addChild('option');
178: $labelValue = $itemsXmlObj->escapeXml($_option['label']);
179: $optionXml->addAttribute('label', $labelValue);
180: $textValue = $itemsXmlObj->escapeXml($_formattedOptionValue['value']);
181: $optionXml->addAttribute('text', $textValue);
182: }
183: }
184: }
185:
186: return $itemsXmlObj->asNiceXml();
187: }
188: }
189: