00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Bundle 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Adminhtml sales order item renderer 00030 * 00031 * @category Mage 00032 * @package Mage_Bundle 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 class Mage_Bundle_Block_Adminhtml_Sales_Order_View_Items_Renderer extends Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default 00036 { 00037 public function isShipmentSeparately($item = null) 00038 { 00039 if ($item) { 00040 if ($parentItem = $item->getParentItem()) { 00041 if ($options = $parentItem->getProductOptions()) { 00042 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { 00043 return true; 00044 } else { 00045 return false; 00046 } 00047 } 00048 } else { 00049 if ($options = $item->getProductOptions()) { 00050 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { 00051 return false; 00052 } else { 00053 return true; 00054 } 00055 } 00056 } 00057 } 00058 00059 if ($options = $this->getOrderItem()->getProductOptions()) { 00060 if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { 00061 return true; 00062 } 00063 } 00064 return false; 00065 } 00066 00067 public function isChildCalculated($item = null) 00068 { 00069 if ($item) { 00070 if ($parentItem = $item->getParentItem()) { 00071 if ($options = $parentItem->getProductOptions()) { 00072 if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { 00073 return true; 00074 } else { 00075 return false; 00076 } 00077 } 00078 } else { 00079 if ($options = $item->getProductOptions()) { 00080 if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { 00081 return false; 00082 } else { 00083 return true; 00084 } 00085 } 00086 } 00087 } 00088 00089 if ($options = $this->getItem()->getProductOptions()) { 00090 if (isset($options['product_calculations']) 00091 && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { 00092 return true; 00093 } 00094 } 00095 return false; 00096 } 00097 00098 public function getSelectionAttributes($item) { 00099 if ($item instanceof Mage_Sales_Model_Order_Item) { 00100 $options = $item->getProductOptions(); 00101 } else { 00102 $options = $item->getOrderItem()->getProductOptions(); 00103 } 00104 if (isset($options['bundle_selection_attributes'])) { 00105 return unserialize($options['bundle_selection_attributes']); 00106 } 00107 return null; 00108 } 00109 00110 public function getOrderOptions() 00111 { 00112 $result = array(); 00113 if ($options = $this->getItem()->getProductOptions()) { 00114 if (isset($options['options'])) { 00115 $result = array_merge($result, $options['options']); 00116 } 00117 if (isset($options['additional_options'])) { 00118 $result = array_merge($result, $options['additional_options']); 00119 } 00120 if (!empty($options['attributes_info'])) { 00121 $result = array_merge($options['attributes_info'], $result); 00122 } 00123 } 00124 return $result; 00125 } 00126 00127 public function getValueHtml($item) 00128 { 00129 $result = $this->htmlEscape($item->getName()); 00130 if (!$this->isShipmentSeparately($item)) { 00131 if ($attributes = $this->getSelectionAttributes($item)) { 00132 $result = sprintf('%d', $attributes['qty']) . ' x ' . $result; 00133 } 00134 } 00135 if (!$this->isChildCalculated($item)) { 00136 if ($attributes = $this->getSelectionAttributes($item)) { 00137 $result .= " " . $this->getItem()->getOrder()->formatPrice($attributes['price']); 00138 } 00139 } 00140 return $result; 00141 } 00142 00143 public function canShowPriceInfo($item) 00144 { 00145 if (($item->getParentItem() && $this->isChildCalculated()) 00146 || (!$item->getParentItem() && !$this->isChildCalculated())) { 00147 return true; 00148 } 00149 return false; 00150 } 00151 }