PageRenderTime 46ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/magento/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Default.php

https://bitbucket.org/jit_bec/shopifine
PHP | 617 lines | 498 code | 17 blank | 102 comment | 96 complexity | 2f43f7068ca30e03298e04424b8d1dda MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_XmlConnect
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Default product price xml renderer
  28. *
  29. * @category Mage
  30. * @package Mage_XmlConnect
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_Block_Product_Price
  34. {
  35. /**
  36. * Collect product prices to specified item xml object
  37. *
  38. * @param Mage_Catalog_Model_Product $product
  39. * @param Mage_XmlConnect_Model_Simplexml_Element $item
  40. */
  41. public function collectProductPrices(
  42. Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
  43. ) {
  44. $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
  45. $priceXmlObj = $item->addChild('price');
  46. $_tierPrices = $this->_getTierPrices($product);
  47. if (count($_tierPrices) > 0) {
  48. $tierPricesTextArray = $this->_getTierPricesTextArray($_tierPrices, $product);
  49. $item->addChild('price_tier', implode(PHP_EOL, $tierPricesTextArray));
  50. }
  51. /** @var $_coreHelper Mage_Core_Helper_Data */
  52. $_coreHelper = $this->helper('core');
  53. /** @var $_weeeHelper Mage_Weee_Helper_Data */
  54. $_weeeHelper = $this->helper('weee');
  55. /** @var $_taxHelper Mage_Tax_Helper_Data */
  56. $_taxHelper = $this->helper('tax');
  57. $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
  58. $_minimalPriceValue = $product->getMinimalPrice();
  59. $_minimalPrice = $_taxHelper->getPrice($product, $_minimalPriceValue, $_simplePricesTax);
  60. if (!$product->isGrouped()) {
  61. $_weeeTaxAmount = $_weeeHelper->getAmountForDisplay($product);
  62. if ($_weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
  63. $_weeeTaxAmount = $_weeeHelper->getAmount($product);
  64. $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForDisplay($product);
  65. }
  66. $_price = $_taxHelper->getPrice($product, $product->getPrice());
  67. $_regularPrice = $_taxHelper->getPrice($product, $product->getPrice(), $_simplePricesTax);
  68. $_finalPrice = $_taxHelper->getPrice($product, $product->getFinalPrice());
  69. $_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getFinalPrice(), true);
  70. $_weeeHelper->getPriceDisplayType();
  71. if ($_finalPrice == $_price) {
  72. if ($_taxHelper->displayBothPrices()) {
  73. /**
  74. * Including
  75. */
  76. if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
  77. $priceXmlObj->addAttribute(
  78. 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
  79. );
  80. $priceXmlObj->addAttribute(
  81. 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
  82. );
  83. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
  84. /**
  85. * Including + Weee
  86. */
  87. $priceXmlObj->addAttribute(
  88. 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
  89. );
  90. $priceXmlObj->addAttribute(
  91. 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
  92. );
  93. $weeeXmlObj = $priceXmlObj->addChild('weee');
  94. $_weeeSeparator = ' + ';
  95. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  96. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  97. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  98. $weeeItemXmlObj->addAttribute(
  99. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  100. );
  101. $weeeItemXmlObj->addAttribute(
  102. 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
  103. );
  104. }
  105. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
  106. /**
  107. * Including + Weee
  108. */
  109. $priceXmlObj->addAttribute(
  110. 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
  111. );
  112. $priceXmlObj->addAttribute(
  113. 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
  114. );
  115. $weeeXmlObj = $priceXmlObj->addChild('weee');
  116. $_weeeSeparator = ' + ';
  117. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  118. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  119. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  120. $weeeItemXmlObj->addAttribute(
  121. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  122. );
  123. $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
  124. $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
  125. ));
  126. }
  127. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
  128. /**
  129. * Excluding + Weee + Final
  130. */
  131. $priceXmlObj->addAttribute('excluding_tax', $_coreHelper->currency($_price, true, false));
  132. $weeeXmlObj = $priceXmlObj->addChild('weee');
  133. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  134. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  135. $weeeItemXmlObj->addAttribute(
  136. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  137. );
  138. $weeeItemXmlObj->addAttribute(
  139. 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
  140. );
  141. }
  142. $priceXmlObj->addAttribute('including_tax', $_coreHelper->currency(
  143. $_finalPriceInclTax + $_weeeTaxAmount, true, false
  144. ));
  145. } else {
  146. $priceXmlObj->addAttribute('excluding_tax', $_coreHelper->currency($_price, true, false));
  147. $priceXmlObj->addAttribute(
  148. 'including_tax', $_coreHelper->currency($_finalPriceInclTax, true, false)
  149. );
  150. }
  151. /**
  152. * if ($_taxHelper->displayBothPrices()) {
  153. */
  154. } else {
  155. /**
  156. * Including
  157. */
  158. if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
  159. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  160. $_price + $_weeeTaxAmount, true, false
  161. ));
  162. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
  163. /**
  164. * Including + Weee
  165. */
  166. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  167. $_price + $_weeeTaxAmount, true, false
  168. ));
  169. $weeeXmlObj = $priceXmlObj->addChild('weee');
  170. $_weeeSeparator = ' + ';
  171. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  172. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  173. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  174. $weeeItemXmlObj->addAttribute(
  175. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  176. );
  177. $weeeItemXmlObj->addAttribute(
  178. 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
  179. );
  180. }
  181. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
  182. /**
  183. * Including + Weee
  184. */
  185. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  186. $_price + $_weeeTaxAmount, true, false
  187. ));
  188. $weeeXmlObj = $priceXmlObj->addChild('weee');
  189. $_weeeSeparator = ' + ';
  190. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  191. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  192. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  193. $weeeItemXmlObj->addAttribute(
  194. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  195. );
  196. $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
  197. $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
  198. ));
  199. }
  200. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
  201. /**
  202. * Excluding + Weee + Final
  203. */
  204. $priceXmlObj->addAttribute(
  205. 'regular', $_coreHelper->currency($_price, true, false)
  206. );
  207. $weeeXmlObj = $priceXmlObj->addChild('weee');
  208. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  209. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  210. $weeeItemXmlObj->addAttribute(
  211. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  212. );
  213. $weeeItemXmlObj->addAttribute(
  214. 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
  215. );
  216. }
  217. $priceXmlObj->addAttribute(
  218. 'including_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
  219. );
  220. } else {
  221. $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_price, true, false));
  222. }
  223. }
  224. /**
  225. * if ($_finalPrice == $_price) {
  226. */
  227. } else {
  228. $_originalWeeeTaxAmount = $_weeeHelper->getOriginalAmount($product);
  229. /**
  230. * Including
  231. */
  232. if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
  233. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  234. $_regularPrice + $_originalWeeeTaxAmount, true, false
  235. ));
  236. if ($_taxHelper->displayBothPrices()) {
  237. $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
  238. $_finalPrice + $_weeeTaxAmount, true, false
  239. ));
  240. $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
  241. $_finalPriceInclTax + $_weeeTaxAmount, true, false
  242. ));
  243. } else {
  244. $priceXmlObj->addAttribute('special', $_coreHelper->currency(
  245. $_finalPrice + $_weeeTaxAmount, true, false
  246. ));
  247. }
  248. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
  249. /**
  250. * Including + Weee
  251. */
  252. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  253. $_regularPrice + $_originalWeeeTaxAmount, true, false
  254. ));
  255. $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
  256. $_finalPrice + $_weeeTaxAmount, true, false
  257. ));
  258. $weeeXmlObj = $priceXmlObj->addChild('weee');
  259. $_weeeSeparator = ' + ';
  260. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  261. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  262. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  263. $weeeItemXmlObj->addAttribute(
  264. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  265. );
  266. $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
  267. $_weeeTaxAttribute->getAmount(), true, false
  268. ));
  269. }
  270. $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
  271. $_finalPriceInclTax + $_weeeTaxAmount, true, false
  272. ));
  273. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
  274. /**
  275. * Including + Weee
  276. */
  277. $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
  278. $_regularPrice + $_originalWeeeTaxAmount, true, false
  279. ));
  280. $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
  281. $_finalPrice + $_weeeTaxAmount, true, false
  282. ));
  283. $weeeXmlObj = $priceXmlObj->addChild('weee');
  284. $_weeeSeparator = ' + ';
  285. $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
  286. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  287. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  288. $weeeItemXmlObj->addAttribute(
  289. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  290. );
  291. $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
  292. $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
  293. ));
  294. }
  295. $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
  296. $_finalPriceInclTax + $_weeeTaxAmount, true, false
  297. ));
  298. } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
  299. /**
  300. * Excluding + Weee + Final
  301. */
  302. $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_regularPrice, true, false));
  303. $priceXmlObj->addAttribute(
  304. 'special_excluding_tax', $_coreHelper->currency($_finalPrice, true, false)
  305. );
  306. $weeeXmlObj = $priceXmlObj->addChild('weee');
  307. foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
  308. $weeeItemXmlObj = $weeeXmlObj->addChild('item');
  309. $weeeItemXmlObj->addAttribute(
  310. 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
  311. );
  312. $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
  313. $_weeeTaxAttribute->getAmount(), true, false
  314. ));
  315. }
  316. $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
  317. $_finalPriceInclTax + $_weeeTaxAmount, true, false
  318. ));
  319. } else {
  320. /**
  321. * Excluding
  322. */
  323. $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_regularPrice, true, false));
  324. if ($_taxHelper->displayBothPrices()) {
  325. $priceXmlObj->addAttribute(
  326. 'special_excluding_tax', $_coreHelper->currency($_finalPrice, true, false)
  327. );
  328. $priceXmlObj->addAttribute(
  329. 'special_including_tax', $_coreHelper->currency($_finalPriceInclTax, true, false)
  330. );
  331. } else {
  332. $priceXmlObj->addAttribute(
  333. 'special', $_coreHelper->currency($_finalPrice, true, false)
  334. );
  335. }
  336. }
  337. }
  338. if ($this->getDisplayMinimalPrice()
  339. && $_minimalPriceValue
  340. && $_minimalPriceValue < $product->getFinalPrice()
  341. ) {
  342. $_minimalPriceDisplayValue = $_minimalPrice;
  343. if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
  344. $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount;
  345. }
  346. if (!$this->getUseLinkForAsLowAs()) {
  347. $priceXmlObj->addAttribute('as_low_as', $_coreHelper->currency(
  348. $_minimalPriceDisplayValue, true, false
  349. ));
  350. }
  351. }
  352. /**
  353. * if (!$product->isGrouped()) {
  354. */
  355. } else {
  356. $_exclTax = $_taxHelper->getPrice($product, $_minimalPriceValue, null);
  357. $_inclTax = $_taxHelper->getPrice($product, $_minimalPriceValue, true);
  358. if ($this->getDisplayMinimalPrice() && $_minimalPriceValue) {
  359. if ($_taxHelper->displayBothPrices()) {
  360. $priceXmlObj->addAttribute('starting_at_excluding_tax', $_coreHelper->currency(
  361. $_exclTax, true, false
  362. ));
  363. $priceXmlObj->addAttribute('starting_at_including_tax', $_coreHelper->currency(
  364. $_inclTax, true, false
  365. ));
  366. } else {
  367. $_showPrice = $_inclTax;
  368. if (!$_taxHelper->displayPriceIncludingTax()) {
  369. $_showPrice = $_exclTax;
  370. }
  371. $priceXmlObj->addAttribute('starting_at', $_coreHelper->currency($_showPrice, true, false));
  372. }
  373. }
  374. }
  375. }
  376. /**
  377. * Get tier prices (formatted)
  378. *
  379. * @param Mage_Catalog_Model_Product $product
  380. * @return array
  381. */
  382. protected function _getTierPrices(Mage_Catalog_Model_Product $product)
  383. {
  384. if (is_null($product)) {
  385. return array();
  386. }
  387. $prices = $product->getFormatedTierPrice();
  388. $res = array();
  389. if (is_array($prices)) {
  390. foreach ($prices as $price) {
  391. $price['price_qty'] = $price['price_qty']*1;
  392. if ($product->getPrice() != $product->getFinalPrice()) {
  393. if ($price['price'] < $product->getFinalPrice()) {
  394. $price['savePercent'] = ceil(100 - ((100 / $product->getFinalPrice()) * $price['price']));
  395. $price['formated_price'] = Mage::app()->getStore()->formatPrice(
  396. Mage::app()->getStore()->convertPrice(
  397. Mage::helper('tax')->getPrice($product, $price['website_price'])
  398. ),
  399. false
  400. );
  401. $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
  402. Mage::app()->getStore()->convertPrice(
  403. Mage::helper('tax')->getPrice($product, $price['website_price'], true)
  404. ),
  405. false
  406. );
  407. $res[] = $price;
  408. }
  409. } else {
  410. if ($price['price'] < $product->getPrice()) {
  411. $price['savePercent'] = ceil(100 - ((100 / $product->getPrice()) * $price['price']));
  412. $price['formated_price'] = Mage::app()->getStore()->formatPrice(
  413. Mage::app()->getStore()->convertPrice(
  414. Mage::helper('tax')->getPrice($product, $price['website_price'])
  415. ),
  416. false
  417. );
  418. $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
  419. Mage::app()->getStore()->convertPrice(
  420. Mage::helper('tax')->getPrice($product, $price['website_price'], true)
  421. ),
  422. false
  423. );
  424. $res[] = $price;
  425. }
  426. }
  427. }
  428. }
  429. return $res;
  430. }
  431. /**
  432. * Get tier prices (formatted) as array of strings
  433. *
  434. * @param array $_tierPrices
  435. * @param Mage_Catalog_Model_Product $_product
  436. *
  437. * @return array
  438. */
  439. protected function _getTierPricesTextArray($_tierPrices, $_product)
  440. {
  441. $pricesArray = array();
  442. if (Mage::helper('weee')->typeOfDisplay($_product, array(1, 2, 4))) {
  443. $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
  444. }
  445. if ($_product->isGrouped()) {
  446. $_tierPrices = $this->getTierPrices($_product);
  447. }
  448. Mage::helper('weee')->processTierPrices($_product, $_tierPrices);
  449. foreach ($_tierPrices as $_price) {
  450. $s = '';
  451. if ($this->helper('tax')->displayBothPrices()) {
  452. if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
  453. $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']);
  454. } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
  455. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
  456. if ($_weeeTaxAttributes) {
  457. $s .= '(' . $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
  458. $separator = ' + ';
  459. foreach ($_weeeTaxAttributes as $_attribute) {
  460. $s .= $separator . $_attribute->getName() . ': ';
  461. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  462. }
  463. $s .= ')';
  464. }
  465. $s .= $this->__('each');
  466. } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
  467. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
  468. if ($_weeeTaxAttributes) {
  469. $s .= '(' . $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
  470. $separator = ' + ';
  471. foreach ($_weeeTaxAttributes as $_attribute) {
  472. $s .= $separator . $_attribute->getName() . ': ';
  473. $s .= Mage::helper('core')->currency(
  474. $_attribute->getAmount() + $_attribute->getTaxAmount()
  475. );
  476. }
  477. $s .= ')';
  478. }
  479. $s .= $this->__('each');
  480. } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
  481. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
  482. if ($_weeeTaxAttributes) {
  483. $s .= '(';
  484. foreach ($_weeeTaxAttributes as $_attribute) {
  485. $s .= $_attribute->getName() . ': ';
  486. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  487. }
  488. $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']) . ')';
  489. }
  490. $s .= $this->__('each');
  491. } else {
  492. $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']);
  493. }
  494. } else {
  495. if ($this->helper('tax')->displayPriceIncludingTax()) {
  496. if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
  497. $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']);
  498. } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
  499. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
  500. if ($_weeeTaxAttributes) {
  501. $s .= '(';
  502. $separator = '';
  503. foreach ($_weeeTaxAttributes as $_attribute) {
  504. $s .= $separator . $_attribute->getName() . ': ';
  505. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  506. $separator = ' + ';
  507. }
  508. $s .= ')';
  509. }
  510. $s .= $this->__('each');
  511. } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
  512. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
  513. if ($_weeeTaxAttributes) {
  514. $s .= '(';
  515. $separator = '';
  516. foreach ($_weeeTaxAttributes as $_attribute) {
  517. $s .= $separator . $_attribute->getName() . ': ';
  518. $s .= Mage::helper('core')->currency(
  519. $_attribute->getAmount() + $_attribute->getTaxAmount()
  520. );
  521. $separator = ' + ';
  522. }
  523. $s .= ')';
  524. }
  525. $s .= $this->__('each');
  526. } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
  527. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']);
  528. if ($_weeeTaxAttributes) {
  529. $s .= '(';
  530. foreach ($_weeeTaxAttributes as $_attribute) {
  531. $s .= $_attribute->getName() . ': ';
  532. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  533. }
  534. $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']) . ')';
  535. }
  536. $s .= $this->__('each');
  537. } else {
  538. $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']);
  539. }
  540. } else {
  541. if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
  542. $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
  543. } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
  544. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
  545. if ($_weeeTaxAttributes) {
  546. $s .= '(';
  547. $separator = '';
  548. foreach ($_weeeTaxAttributes as $_attribute) {
  549. $s .= $separator . $_attribute->getName() . ': ';
  550. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  551. $separator = ' + ';
  552. }
  553. $s .= ')';
  554. }
  555. $s .= $this->__('each');
  556. } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
  557. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
  558. if ($_weeeTaxAttributes) {
  559. $s .= '(';
  560. $separator = '';
  561. foreach ($_weeeTaxAttributes as $_attribute) {
  562. $s .= $separator . $_attribute->getName() . ': ';
  563. $s .= Mage::helper('core')->currency(
  564. $_attribute->getAmount() + $_attribute->getTaxAmount()
  565. );
  566. $separator = ' + ';
  567. }
  568. $s .= ')';
  569. }
  570. $s .= $this->__('each');
  571. } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
  572. $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
  573. if ($_weeeTaxAttributes) {
  574. $s .= '(';
  575. foreach ($_weeeTaxAttributes as $_attribute) {
  576. $s .= $_attribute->getName() . ': ';
  577. $s .= Mage::helper('core')->currency($_attribute->getAmount());
  578. }
  579. $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']) . ')';
  580. }
  581. $s .= $this->__('each');
  582. } else {
  583. $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']);
  584. }
  585. }
  586. }
  587. if (!$_product->isGrouped()) {
  588. $condition1 = ($_product->getPrice() == $_product->getFinalPrice()
  589. && $_product->getPrice() > $_price['price']);
  590. $condition2 = ($_product->getPrice() != $_product->getFinalPrice()
  591. && $_product->getFinalPrice() > $_price['price']);
  592. if ($condition1 || $condition2) {
  593. $s .= ' ' . $this->__('and') . ' ' . $this->__('save') . ' ' . $_price['savePercent'] . '%';
  594. }
  595. }
  596. $pricesArray[] = $s;
  597. }
  598. return $pricesArray;
  599. }
  600. }