FranciscoPrado_PrecoParcelado - Version 3.0.0.0

Version Notes

- Opção de exibir parcela à vista na tabela
- Opção de cálculo com juros a partir de determinado mês
- Opção de exibir informação de juros ao lado do preço

Download this release

Release Info

Developer Francisco Prado
Extension FranciscoPrado_PrecoParcelado
Version 3.0.0.0
Comparing to
See all releases


Code changes from version 2.0.0.2 to 3.0.0.0

app/code/community/FranciscoPrado/PrecoParcelado/Helper/Data.php CHANGED
@@ -12,6 +12,11 @@ class FranciscoPrado_PrecoParcelado_Helper_Data extends Mage_Core_Helper_Abstrac
12
  const XML_PATH_TEXT_PATTERN = 'sales/franciscoprado_precoparcelado/text_pattern';
13
  const XML_PATH_TABLE_TEXT_PATTERN = 'sales/franciscoprado_precoparcelado/text_table_pattern';
14
  const XML_PATH_ADD_JQUERY = 'sales/franciscoprado_precoparcelado/add_jquery';
 
 
 
 
 
15
 
16
  public function isModuleEnabled($moduleName = null) {
17
  if ((int) Mage::getStoreConfig(self::XML_PATH_ACTIVE, Mage::app()->getStore()) != 1) {
@@ -56,16 +61,43 @@ class FranciscoPrado_PrecoParcelado_Helper_Data extends Mage_Core_Helper_Abstrac
56
  return Mage::getStoreConfig(self::XML_PATH_ADD_JQUERY, $store);
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  public function getParcelsValue($value, $interest, $parcel) {
60
  $interest = bcdiv($interest, 100, 15);
 
61
  $E = 1.0;
62
  $cont = 1.0;
63
 
64
  for ($i = 1; $i <= $parcel; $i++) {
65
- $cont = bcmul($cont, bcadd($interest, 1, 15), 15);
 
 
 
 
 
 
66
  $E = bcadd($E, $cont, 15);
67
  }
68
-
69
  $E = bcsub($E, $cont, 15);
70
 
71
  $value = bcmul($value, $cont, 15);
@@ -85,6 +117,12 @@ class FranciscoPrado_PrecoParcelado_Helper_Data extends Mage_Core_Helper_Abstrac
85
  $price = Mage::helper('core')->currency($parcel, true, false);
86
  $replaceText = str_replace('{parcelas}', $i, $this->getText());
87
  $finalText = str_replace('{preco}', $price, $replaceText);
 
 
 
 
 
 
88
  }
89
  }
90
 
12
  const XML_PATH_TEXT_PATTERN = 'sales/franciscoprado_precoparcelado/text_pattern';
13
  const XML_PATH_TABLE_TEXT_PATTERN = 'sales/franciscoprado_precoparcelado/text_table_pattern';
14
  const XML_PATH_ADD_JQUERY = 'sales/franciscoprado_precoparcelado/add_jquery';
15
+ const XML_PATH_INTEREST_FROM = 'sales/franciscoprado_precoparcelado/interest_from';
16
+ const XML_PATH_TEXT_WITH_INTEREST = 'sales/franciscoprado_precoparcelado/text_with_interest';
17
+ const XML_PATH_TEXT_WITHOUT_INTEREST = 'sales/franciscoprado_precoparcelado/text_without_interest';
18
+ const XML_PATH_SHOW_SINGLE_PARCEL_TEXT = 'sales/franciscoprado_precoparcelado/show_single_parcel_text';
19
+ const XML_PATH_TEXT_TABLE_SINGLE_PRICE = 'sales/franciscoprado_precoparcelado/text_table_single_price';
20
 
21
  public function isModuleEnabled($moduleName = null) {
22
  if ((int) Mage::getStoreConfig(self::XML_PATH_ACTIVE, Mage::app()->getStore()) != 1) {
61
  return Mage::getStoreConfig(self::XML_PATH_ADD_JQUERY, $store);
62
  }
63
 
64
+ public function getInterestFrom($store = null) {
65
+ return (float) Mage::getStoreConfig(self::XML_PATH_INTEREST_FROM, $store);
66
+ }
67
+
68
+ public function getTextWithInterest($store = null) {
69
+ return Mage::getStoreConfig(self::XML_PATH_TEXT_WITH_INTEREST, $store);
70
+ }
71
+
72
+ public function getTextWithoutInterest($store = null) {
73
+ return Mage::getStoreConfig(self::XML_PATH_TEXT_WITHOUT_INTEREST, $store);
74
+ }
75
+
76
+ public function showSingleParcelText($store = null) {
77
+ return (float) Mage::getStoreConfig(self::XML_PATH_SHOW_SINGLE_PARCEL_TEXT, $store);
78
+ }
79
+
80
+ public function getTextSinglePrice($store = null) {
81
+ return Mage::getStoreConfig(self::XML_PATH_TEXT_TABLE_SINGLE_PRICE, $store);
82
+ }
83
+
84
  public function getParcelsValue($value, $interest, $parcel) {
85
  $interest = bcdiv($interest, 100, 15);
86
+ $final_interest = 0;
87
  $E = 1.0;
88
  $cont = 1.0;
89
 
90
  for ($i = 1; $i <= $parcel; $i++) {
91
+ if ($i >= $this->getInterestFrom()) {
92
+ $final_interest = $interest;
93
+ } else {
94
+ $final_interest = 0;
95
+ }
96
+
97
+ $cont = bcmul($cont, bcadd($final_interest, 1, 15), 15);
98
  $E = bcadd($E, $cont, 15);
99
  }
100
+
101
  $E = bcsub($E, $cont, 15);
102
 
103
  $value = bcmul($value, $cont, 15);
117
  $price = Mage::helper('core')->currency($parcel, true, false);
118
  $replaceText = str_replace('{parcelas}', $i, $this->getText());
119
  $finalText = str_replace('{preco}', $price, $replaceText);
120
+
121
+ if ($i >= $this->getInterestFrom()) {
122
+ $finalText .= $this->getTextWithInterest();
123
+ } else {
124
+ $finalText .= $this->getTextWithoutInterest();
125
+ }
126
  }
127
  }
128
 
app/code/community/FranciscoPrado/PrecoParcelado/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <FranciscoPrado_PrecoParcelado>
5
- <version>2.0.0.2</version>
6
  </FranciscoPrado_PrecoParcelado>
7
  </modules>
8
  <global>
@@ -65,8 +65,13 @@
65
  <min_quote_value>50</min_quote_value>
66
  <max_number_months>12</max_number_months>
67
  <interest_value>1</interest_value>
 
68
  <text_pattern>ou em {parcelas} vezes de {preco}</text_pattern>
69
  <text_table_pattern>{parcelas}x de</text_table_pattern>
 
 
 
 
70
  <add_jquery>0</add_jquery>
71
  </franciscoprado_precoparcelado>
72
  </sales>
2
  <config>
3
  <modules>
4
  <FranciscoPrado_PrecoParcelado>
5
+ <version>3.0.0.0</version>
6
  </FranciscoPrado_PrecoParcelado>
7
  </modules>
8
  <global>
65
  <min_quote_value>50</min_quote_value>
66
  <max_number_months>12</max_number_months>
67
  <interest_value>1</interest_value>
68
+ <interest_from>0</interest_from>
69
  <text_pattern>ou em {parcelas} vezes de {preco}</text_pattern>
70
  <text_table_pattern>{parcelas}x de</text_table_pattern>
71
+ <text_with_interest></text_with_interest>
72
+ <text_without_interest> Sem Juros</text_without_interest>
73
+ <show_single_parcel_text>0</show_single_parcel_text>
74
+ <text_table_single_price>à vista</text_table_single_price>
75
  <add_jquery>0</add_jquery>
76
  </franciscoprado_precoparcelado>
77
  </sales>
app/code/community/FranciscoPrado/PrecoParcelado/etc/system.xml CHANGED
@@ -78,6 +78,18 @@
78
  <show_in_store>0</show_in_store>
79
  <validate>validate-zero-or-greater</validate>
80
  </interest_value>
 
 
 
 
 
 
 
 
 
 
 
 
81
  <text_pattern>
82
  <label>Text Pattern</label>
83
  <frontend_type>text</frontend_type>
@@ -100,6 +112,45 @@
100
  O {parcelas} é necessário e substituirá pela quantidade de parcelas na apresentação.
101
  </comment>
102
  </text_table_pattern>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  <add_jquery>
104
  <label>Add jQuery?</label>
105
  <sort_order>110</sort_order>
78
  <show_in_store>0</show_in_store>
79
  <validate>validate-zero-or-greater</validate>
80
  </interest_value>
81
+ <interest_from>
82
+ <label>Interest From Parcel</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>70</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ <validate>validate-zero-or-greater</validate>
89
+ <comment>
90
+ Os juros serão calculados a partir de qual parcela/mês?
91
+ </comment>
92
+ </interest_from>
93
  <text_pattern>
94
  <label>Text Pattern</label>
95
  <frontend_type>text</frontend_type>
112
  O {parcelas} é necessário e substituirá pela quantidade de parcelas na apresentação.
113
  </comment>
114
  </text_table_pattern>
115
+ <text_with_interest>
116
+ <label>Text With Interest</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>100</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ </text_with_interest>
123
+ <text_without_interest>
124
+ <label>Text Without Interest</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>100</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>0</show_in_store>
130
+ </text_without_interest>
131
+ <show_single_parcel_text>
132
+ <label>Show Single Parcel In Table?</label>
133
+ <sort_order>101</sort_order>
134
+ <frontend_type>select</frontend_type>
135
+ <source_model>adminhtml/system_config_source_yesno</source_model>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ <comment>
140
+ Selecione Sim se deseja exibir o preço à vista na tabela. Caso Não, a tabela exibirá a partir da segunda parcela.
141
+ </comment>
142
+ </show_single_parcel_text>
143
+ <text_table_single_price>
144
+ <label>Table Text Single Price</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>102</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ <comment>
151
+ O texto para parcela única (à vista) caso exibido.
152
+ </comment>
153
+ </text_table_single_price>
154
  <add_jquery>
155
  <label>Add jQuery?</label>
156
  <sort_order>110</sort_order>
app/design/frontend/base/default/layout/franciscoprado_precoparcelado.xml DELETED
@@ -1,18 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <catalog_product_view>
4
- <reference name="head">
5
- <action method="addItem">
6
- <type>skin_css</type>
7
- <script>css/precoparcelado.css</script>
8
- <params><![CDATA[media="all"]]></params>
9
- </action>
10
- </reference>
11
- <reference name="product.info.extrahint">
12
- <block type="core/template" name="precoparcelado.table" template="precoparcelado/table.phtml" before="-" />
13
- </reference>
14
- <reference name="content">
15
- <block type="core/template" name="precoparcelado.jsdata" template="precoparcelado/jsdata.phtml" before="-" />
16
- </reference>
17
- </catalog_product_view>
18
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/precoparcelado/table.phtml CHANGED
@@ -11,33 +11,48 @@ if ($isActive && $showTable):
11
  ?>
12
  <table class="precoparcelado-table">
13
  <thead>
14
- <tr>
15
- <th colspan="2"><?php echo $helper->getTableTitle() ?></th>
16
- </tr>
17
  </thead>
18
  <tbody>
19
- <?php
20
- if ($productPrice > $minParcelValue):
21
- for ($i = 2; $i <= $maxNumberMonths; $i++):
22
-
23
- $parcel = $helper->getParcelsValue($productPrice, $interest, $i);
24
-
25
- $tableText = str_replace('{parcelas}', $i, $helper->getTableText());
26
- $parcelPrice = Mage::helper('core')->currency($parcel, true, false);
27
-
28
- if ($parcel >= $minParcelValue):
29
- ?>
30
- <tr>
31
- <td><?php echo $tableText ?></td>
32
- <td><?php echo $parcelPrice ?></td>
33
- <tr>
34
- <?php
35
- endif;
36
- endfor;
37
- endif;
38
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  </tbody>
40
  </table>
41
  <?php
42
 
 
43
  endif;
11
  ?>
12
  <table class="precoparcelado-table">
13
  <thead>
14
+ <tr>
15
+ <th colspan="2"><?php echo $helper->getTableTitle() ?></th>
16
+ </tr>
17
  </thead>
18
  <tbody>
19
+ <?php
20
+ if ($productPrice > $minParcelValue):
21
+ for ($i = 1; $i <= $maxNumberMonths; $i++):
22
+
23
+ if (!$helper->showSingleParcelText() && $i == 1)
24
+ continue;
25
+
26
+ $parcel = $helper->getParcelsValue($productPrice, $interest, $i);
27
+
28
+ if ($helper->showSingleParcelText() && $i == 1) {
29
+ $tableText = $helper->getTextSinglePrice();
30
+ } else {
31
+ $tableText = str_replace('{parcelas}', $i, $helper->getTableText());
32
+ }
33
+
34
+ $parcelPrice = Mage::helper('core')->currency($parcel, true, false);
35
+
36
+ if ($i >= $helper->getInterestFrom()) {
37
+ $parcelPrice .= $helper->getTextWithInterest();
38
+ } else {
39
+ $parcelPrice .= $helper->getTextWithoutInterest();
40
+ }
41
+
42
+ if ($parcel >= $minParcelValue):
43
+ ?>
44
+ <tr>
45
+ <td><?php echo $tableText ?></td>
46
+ <td><?php echo $parcelPrice ?></td>
47
+ <tr>
48
+ <?php
49
+ endif;
50
+ endfor;
51
+ endif;
52
+ ?>
53
  </tbody>
54
  </table>
55
  <?php
56
 
57
+
58
  endif;
app/locale/pt_BR/FranciscoPrado_PrecoParcelado.csv CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  "Parcels Value", "Valor das Parcelas"
2
  "Show Parcel Table", "Mostrar Tabela de Parcelas"
3
  "Table Title", "Título da Tabela"
@@ -8,4 +11,9 @@
8
  "Use Compound Interest?", "Usar Juros Compostos?"
9
  "Text Pattern", "Padrão do Texto"
10
  "Table Text Pattern", "Padrão do Texto da Tabela"
11
- "Add jQuery?", "Adicionar jQuery?"
 
 
 
 
 
1
+ "Enable", "Ativado"
2
+ "Yes", "Sim"
3
+ "No", "Não"
4
  "Parcels Value", "Valor das Parcelas"
5
  "Show Parcel Table", "Mostrar Tabela de Parcelas"
6
  "Table Title", "Título da Tabela"
11
  "Use Compound Interest?", "Usar Juros Compostos?"
12
  "Text Pattern", "Padrão do Texto"
13
  "Table Text Pattern", "Padrão do Texto da Tabela"
14
+ "Add jQuery?", "Adicionar jQuery?"
15
+ "Interest From Parcel", "Juros a Partir da Parcela"
16
+ "Text With Interest", "Texto 'Com Juros'"
17
+ "Text Without Interest", "Texto 'Sem Juros'"
18
+ "Show Single Parcel In Table?", "Mostrar Preço à Vista na Tabela?"
19
+ "Table Text Single Price", "Texto do Preço à Vista"
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FranciscoPrado_PrecoParcelado</name>
4
- <version>2.0.0.2</version>
5
  <stability>stable</stability>
6
- <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>M&#xF3;dulo para mostrar o pre&#xE7;o do produto em forma de parcelas, que &#xE9; um tipo de pagamento comum no Brasil.</summary>
10
- <description>M&#xF3;dulo para mostrar o pre&#xE7;o do produto em forma de parcelas, que &#xE9; um tipo de pagamento comum no Brasil.</description>
11
- <notes>Corre&#xE7;&#xE3;o no modo de c&#xE1;lculo, que passa a usar somente a tabela Price.</notes>
 
 
12
  <authors><author><name>Francisco Prado</name><user>fr_prado</user><email>franciscontato@gmail.com</email></author></authors>
13
- <date>2014-10-13</date>
14
- <time>20:59:48</time>
15
- <contents><target name="mageetc"><dir><dir name="modules"><file name="FranciscoPrado_PrecoParcelado.xml" hash="ff2352dd5dcf370b98b77782ac230e5f"/></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="precoparcelado"><file name="jsdata.phtml" hash="7c05341c50664fc28ee9b5027e5bcc5e"/><file name="table.phtml" hash="66c9a9bd9785ed6fb2689b70b2c8e3c8"/></dir></dir><dir name="layout"><file name="franciscoprado_precoparcelado.xml" hash="2e78e3b82b16ca71f4f678ae89c6930e"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="FranciscoPrado_PrecoParcelado.csv" hash="20d484ae51b10f0bda926502b383a61d"/></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="precoparcelado.js" hash="9d048b9ee02ef4b9c62b0d0c2b8bb846"/></dir><dir name="css"><file name="precoparcelado.css" hash="8b127443908efc0529ff9953e4d1402e"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir><dir name="FranciscoPrado"><dir name="PrecoParcelado"><dir><dir name="etc"><file name="config.xml" hash="a5c1038b7b7d39a14e7f8142faedb2fd"/><file name="system.xml" hash="7adf1173acb4fe428b02d088bac35ec8"/></dir><dir name="Helper"><file name="Data.php" hash="86b19fe600259fbef62975e04115f9b4"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FranciscoPrado_PrecoParcelado</name>
4
+ <version>3.0.0.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl- 3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>M&#xF3;dulo para mostrar o pre&#xE7;o do produto em forma de parcelas, que &#xE9; um tipo de pagamento comum no Brasil.</summary>
10
+ <description>Com esta extens&#xE3;o &#xE9; poss&#xED;vel voc&#xEA; mostrar o pre&#xE7;o parcelado do seu produto. Atrav&#xE9;s do painel de administra&#xE7;&#xE3;o &#xE9; poss&#xED;vel configurar os modos de exibi&#xE7;&#xE3;o (tabela de parcelas ou em texto espec&#xED;fico), n&#xFA;mero de meses, valor do juros, parcela m&#xED;nima, entre outros.</description>
11
+ <notes>- Op&#xE7;&#xE3;o de exibir parcela &#xE0; vista na tabela&#xD;
12
+ - Op&#xE7;&#xE3;o de c&#xE1;lculo com juros a partir de determinado m&#xEA;s&#xD;
13
+ - Op&#xE7;&#xE3;o de exibir informa&#xE7;&#xE3;o de juros ao lado do pre&#xE7;o</notes>
14
  <authors><author><name>Francisco Prado</name><user>fr_prado</user><email>franciscontato@gmail.com</email></author></authors>
15
+ <date>2015-11-13</date>
16
+ <time>13:01:29</time>
17
+ <contents><target name="magecommunity"><dir name="FranciscoPrado"><dir name="PrecoParcelado"><dir name="Helper"><file name="Data.php" hash="723424a15f473eec46cc4d47583e6e07"/></dir><dir name="etc"><file name="config.xml" hash="7a9d0a2cafc2e8650c2191e1de77a15a"/><file name="system.xml" hash="28074728f78b3083b41f78dcd3f39a80"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layou"><file name="franciscoprado_precoparcelado.xml" hash=""/></dir><dir name="template"><dir name="precoparcelado"><file name="jsdata.phtml" hash="7c05341c50664fc28ee9b5027e5bcc5e"/><file name="table.phtml" hash="e1d3f82ccbca6586755a53f5a58b5568"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FranciscoPrado_PrecoParcelado.xml" hash="ff2352dd5dcf370b98b77782ac230e5f"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="FranciscoPrado_PrecoParcelado.csv" hash="4955e05a351fd096833bd4624e573ecc"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="precoparcelado.css" hash="8b127443908efc0529ff9953e4d1402e"/></dir><dir name="js"><file name="precoparcelado.js" hash="9d048b9ee02ef4b9c62b0d0c2b8bb846"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>