00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Bundle_Block_Sales_Order_Items_Renderer extends Mage_Sales_Block_Order_Item_Renderer_Default
00035 {
00036 public function isShipmentSeparately($item = null)
00037 {
00038 if ($item) {
00039 if ($item->getOrderItem()) {
00040 $item = $item->getOrderItem();
00041 }
00042 if ($parentItem = $item->getParentItem()) {
00043 if ($options = $parentItem->getProductOptions()) {
00044 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
00045 return true;
00046 } else {
00047 return false;
00048 }
00049 }
00050 } else {
00051 if ($options = $item->getProductOptions()) {
00052 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
00053 return false;
00054 } else {
00055 return true;
00056 }
00057 }
00058 }
00059 }
00060
00061 if ($options = $this->getOrderItem()->getProductOptions()) {
00062 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
00063 return true;
00064 }
00065 }
00066 return false;
00067 }
00068
00069 public function isChildCalculated($item = null)
00070 {
00071 if ($item) {
00072 if ($item->getOrderItem()) {
00073 $item = $item->getOrderItem();
00074 }
00075 if ($parentItem = $item->getParentItem()) {
00076 if ($options = $parentItem->getProductOptions()) {
00077 if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
00078 return true;
00079 } else {
00080 return false;
00081 }
00082 }
00083 } else {
00084 if ($options = $item->getProductOptions()) {
00085 if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
00086 return false;
00087 } else {
00088 return true;
00089 }
00090 }
00091 }
00092 }
00093
00094 if ($options = $this->getOrderItem()->getProductOptions()) {
00095 if (isset($options['product_calculations'])
00096 && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
00097 return true;
00098 }
00099 }
00100 return false;
00101 }
00102
00103 public function getSelectionAttributes($item) {
00104 if ($item instanceof Mage_Sales_Model_Order_Item) {
00105 $options = $item->getProductOptions();
00106 } else {
00107 $options = $item->getOrderItem()->getProductOptions();
00108 }
00109 if (isset($options['bundle_selection_attributes'])) {
00110 return unserialize($options['bundle_selection_attributes']);
00111 }
00112 return null;
00113 }
00114
00115 public function getValueHtml($item)
00116 {
00117 if ($attributes = $this->getSelectionAttributes($item)) {
00118 return sprintf('%d', $attributes['qty']) . ' x ' .
00119 $this->htmlEscape($item->getName()) .
00120 " " . $this->getOrder()->formatPrice($attributes['price']);
00121 } else {
00122 return $this->htmlEscape($item->getName());
00123 }
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 public function getChilds($item)
00133 {
00134 $_itemsArray = array();
00135
00136 if ($item instanceof Mage_Sales_Model_Order_Invoice_Item) {
00137 $_items = $item->getInvoice()->getAllItems();
00138 } else if ($item instanceof Mage_Sales_Model_Order_Shipment_Item) {
00139 $_items = $item->getShipment()->getAllItems();
00140 } else if ($item instanceof Mage_Sales_Model_Order_Creditmemo_Item) {
00141 $_items = $item->getCreditmemo()->getAllItems();
00142 }
00143
00144 if ($_items) {
00145 foreach ($_items as $_item) {
00146 if ($parentItem = $_item->getOrderItem()->getParentItem()) {
00147 $_itemsArray[$parentItem->getId()][$_item->getOrderItemId()] = $_item;
00148 } else {
00149 $_itemsArray[$_item->getOrderItem()->getId()][$_item->getOrderItemId()] = $_item;
00150 }
00151 }
00152 }
00153
00154 if (isset($_itemsArray[$item->getOrderItem()->getId()])) {
00155 return $_itemsArray[$item->getOrderItem()->getId()];
00156 } else {
00157 return null;
00158 }
00159 }
00160
00161 public function canShowPriceInfo($item)
00162 {
00163 if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated())
00164 || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated())) {
00165 return true;
00166 }
00167 return false;
00168 }
00169 }