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:
35: class Mage_Bundle_Block_Adminhtml_Sales_Order_View_Items_Renderer extends Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default
36: {
37: public function isShipmentSeparately($item = null)
38: {
39: if ($item) {
40: if ($parentItem = $item->getParentItem()) {
41: if ($options = $parentItem->getProductOptions()) {
42: if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
43: return true;
44: } else {
45: return false;
46: }
47: }
48: } else {
49: if ($options = $item->getProductOptions()) {
50: if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
51: return false;
52: } else {
53: return true;
54: }
55: }
56: }
57: }
58:
59: if ($options = $this->getOrderItem()->getProductOptions()) {
60: if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
61: return true;
62: }
63: }
64: return false;
65: }
66:
67: public function isChildCalculated($item = null)
68: {
69: if ($item) {
70: if ($parentItem = $item->getParentItem()) {
71: if ($options = $parentItem->getProductOptions()) {
72: if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
73: return true;
74: } else {
75: return false;
76: }
77: }
78: } else {
79: if ($options = $item->getProductOptions()) {
80: if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
81: return false;
82: } else {
83: return true;
84: }
85: }
86: }
87: }
88:
89: if ($options = $this->getItem()->getProductOptions()) {
90: if (isset($options['product_calculations'])
91: && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
92: return true;
93: }
94: }
95: return false;
96: }
97:
98: public function getSelectionAttributes($item) {
99: if ($item instanceof Mage_Sales_Model_Order_Item) {
100: $options = $item->getProductOptions();
101: } else {
102: $options = $item->getOrderItem()->getProductOptions();
103: }
104: if (isset($options['bundle_selection_attributes'])) {
105: return unserialize($options['bundle_selection_attributes']);
106: }
107: return null;
108: }
109:
110: public function getOrderOptions()
111: {
112: $result = array();
113: if ($options = $this->getItem()->getProductOptions()) {
114: if (isset($options['options'])) {
115: $result = array_merge($result, $options['options']);
116: }
117: if (isset($options['additional_options'])) {
118: $result = array_merge($result, $options['additional_options']);
119: }
120: if (!empty($options['attributes_info'])) {
121: $result = array_merge($options['attributes_info'], $result);
122: }
123: }
124: return $result;
125: }
126:
127: public function getValueHtml($item)
128: {
129: $result = $this->htmlEscape($item->getName());
130: if (!$this->isShipmentSeparately($item)) {
131: if ($attributes = $this->getSelectionAttributes($item)) {
132: $result = sprintf('%d', $attributes['qty']) . ' x ' . $result;
133: }
134: }
135: if (!$this->isChildCalculated($item)) {
136: if ($attributes = $this->getSelectionAttributes($item)) {
137: $result .= " " . $this->getItem()->getOrder()->formatPrice($attributes['price']);
138: }
139: }
140: return $result;
141: }
142:
143: public function canShowPriceInfo($item)
144: {
145: if (($item->getParentItem() && $this->isChildCalculated())
146: || (!$item->getParentItem() && !$this->isChildCalculated())) {
147: return true;
148: }
149: return false;
150: }
151: }
152: