1: <?php
2: /*
3:
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * or OpenGPL v3 license (GNU Public License V3.0)
9: * that is bundled with this package in the file LICENSE.txt.
10: * It is also available through the world-wide-web at this URL:
11: * http://opensource.org/licenses/osl-3.0.php
12: * or
13: * http://www.gnu.org/licenses/gpl-3.0.txt
14: * If you did not receive a copy of the license and are unable to
15: * obtain it through the world-wide-web, please send an email
16: * to info@e-abi.ee so we can send you a copy immediately.
17: *
18: * DISCLAIMER
19: *
20: * Do not edit or add to this file if you wish to upgrade this module to newer
21: * versions in the future.
22: *
23: * @category Eabi
24: * @package Eabi_Dpd
25: * @copyright Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
26: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27: * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28: * @author Matis Halmann
29: *
30:
31: */
32:
33: /**
34: * <p>Renders Cash on Delivery description text to order confirmation and e-mail templates</p>
35: * <p>Description is only displayed when merchant sets description for DPD cash on delivery method</p>
36: *
37: * @author Matis
38: */
39: class Eabi_DpdEE_Block_Info_Payment extends Mage_Payment_Block_Info_Cc {
40:
41: const INFO_TEXT = 'info_text';
42:
43:
44: protected $_paymentInfoMap = array(
45: self::INFO_TEXT => 'info_text',
46: );
47: protected $_customerInfoMap = array(
48: self::INFO_TEXT => 'info_text',
49: );
50:
51: public function getCcTypeName() {
52:
53: }
54:
55: /**
56: * <p>Returns <code>info_text</code> field, when merchant decides to display description in cash on delivery method</p>
57: * @param array $transport
58: * @return array
59: */
60: protected function _prepareSpecificInformation($transport = null) {
61: $transport = parent::_prepareSpecificInformation($transport);
62: /* @var $payment Mage_Payment_Model_Info */
63: $payment = $this->getInfo();
64: $info = array();
65: if ($this->getIsSecureMode()) {
66: foreach ($this->_customerInfoMap as $key) {
67: if (!isset($info[$key])) {
68: $info[$key] = array();
69: }
70: if (!$payment->hasAdditionalInformation($key)) {
71: // $info[$key]['label'] = false;
72: // $info[$key]['value'] = false;
73: } else {
74: $value = $payment->getAdditionalInformation($key);
75: if ($value) {
76: $info[$key]['label'] = $this->_getLabel($key);
77: $info[$key]['value'] = $value;
78: }
79: }
80: }
81: } else {
82: foreach ($this->_paymentInfoMap as $key) {
83: if (!isset($info[$key])) {
84: $info[$key] = array();
85: }
86: if (!$payment->hasAdditionalInformation($key)) {
87: $info[$key]['label'] = $this->_getLabel($key);
88: $info[$key]['value'] = false;
89: } else {
90: $value = $payment->getAdditionalInformation($key);
91: if ($value) {
92: $info[$key]['label'] = $this->_getLabel($key);
93: $info[$key]['value'] = $value;
94: }
95: }
96: }
97: }
98: $resultingInfo = array();
99: foreach ($info as $value) {
100: if (isset($value['value']) && trim($value['value']) && isset($value['label'])) {
101: $resultingInfo[$value['label']] = $value['value'];
102: }
103: }
104: if (count($resultingInfo)) {
105: return $transport->addData($resultingInfo);
106: }
107: return $transport;
108:
109: }
110:
111: /**
112: *
113: * @param string $key
114: * @return string
115: */
116: protected function _getLabel($key) {
117: switch ($key) {
118: case self::INFO_TEXT:
119: return $this->_getDpdHelper()->__('Instructions');
120: break;
121: }
122: return '';
123: }
124:
125: /**
126: *
127: * @return Eabi_DpdEE_Helper_Data
128: */
129: protected function _getDpdHelper() {
130: return Mage::helper('eabi_dpdee');
131: }
132:
133:
134: }
135:
136: