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
00035 abstract class Mage_Catalog_Block_Product_View_Options_Abstract extends Mage_Core_Block_Template
00036 {
00037
00038
00039
00040
00041
00042 protected $_product;
00043
00044
00045
00046
00047
00048
00049 protected $_option;
00050
00051
00052
00053
00054
00055
00056
00057 public function setProduct(Mage_Catalog_Model_Product $product = null)
00058 {
00059 $this->_product = $product;
00060 return $this;
00061 }
00062
00063
00064
00065
00066
00067
00068 public function getProduct()
00069 {
00070 return $this->_product;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 public function setOption(Mage_Catalog_Model_Product_Option $option)
00080 {
00081 $this->_option = $option;
00082 return $this;
00083 }
00084
00085
00086
00087
00088
00089
00090 public function getOption()
00091 {
00092 return $this->_option;
00093 }
00094
00095 public function getFormatedPrice()
00096 {
00097 if ($option = $this->getOption()) {
00098 return $this->_formatPrice(array(
00099 'is_percent' => ($option->getPriceType() == 'percent') ? true : false,
00100 'pricing_value' => $option->getPrice(true)
00101 ));
00102 }
00103 return '';
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 protected function _formatPrice($value, $flag=true)
00113 {
00114 if ($value['pricing_value'] == 0) {
00115 return '';
00116 }
00117 $sign = '+';
00118 if ($value['pricing_value'] < 0) {
00119 $sign = '-';
00120 $value['pricing_value'] = 0 - $value['pricing_value'];
00121 }
00122 $priceStr = $sign;
00123 $_priceInclTax = $this->getPrice($value['pricing_value'], true);
00124 $_priceExclTax = $this->getPrice($value['pricing_value']);
00125 if (Mage::helper('tax')->displayPriceIncludingTax()) {
00126 $priceStr .= $this->helper('core')->currency($_priceInclTax, true, $flag);
00127 } elseif (Mage::helper('tax')->displayPriceExcludingTax()) {
00128 $priceStr .= $this->helper('core')->currency($_priceExclTax, true, $flag);
00129 } elseif (Mage::helper('tax')->displayBothPrices()) {
00130 $priceStr .= $this->helper('core')->currency($_priceExclTax, true, $flag);
00131 if ($_priceInclTax != $_priceExclTax) {
00132 $priceStr .= ' ('.$sign.$this->helper('core')
00133 ->currency($_priceInclTax, true, $flag).' '.$this->__('Incl. Tax').')';
00134 }
00135 }
00136
00137 if ($flag) {
00138 $priceStr = '<span class="price-notice">'.$priceStr.'</span>';
00139 }
00140
00141 return $priceStr;
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151 public function getPrice($price, $includingTax = null)
00152 {
00153 if (!is_null($includingTax)) {
00154 $price = Mage::helper('tax')->getPrice($this->getProduct(), $price, true);
00155 } else {
00156 $price = Mage::helper('tax')->getPrice($this->getProduct(), $price);
00157 }
00158 return $price;
00159 }
00160 }