Psquared_PriceRounding - Version 1.0.1

Version Notes

- Fixing wrong extension path

Download this release

Release Info

Developer p squared
Extension Psquared_PriceRounding
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Psquared/PriceRounding/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Psquared_PriceRounding_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/community/Psquared/PriceRounding/Model/Directory/Currency.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Psquared_PriceRounding_Model_Directory_Currency extends Mage_Directory_Model_Currency
3
+ {
4
+ /**
5
+ * Convert price to currency format
6
+ *
7
+ * @param double $price
8
+ * @param string $toCurrency
9
+ * @return double
10
+ */
11
+ public function convert($price, $toCurrency = null) {
12
+ if (is_null($toCurrency)) {
13
+ return $price;
14
+ } elseif ($rate = $this->getRate($toCurrency)) {
15
+ $priceValue = $price * $rate;
16
+ if (Mage::getStoreConfig('catalog/price_rounding/enable_price_rounding') == 1){
17
+ $priceValue = $this->_roundPrice($priceValue);
18
+ }
19
+ return $priceValue;
20
+ }
21
+ throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(), $toCurrency->getCode()));
22
+ }
23
+
24
+ protected function _roundPrice($price) {
25
+ switch (Mage::getStoreConfig('catalog/price_rounding/rounding_method')){
26
+ case 1:
27
+ $roundedPrice = round($price);
28
+ break;
29
+ case 2:
30
+ $roundedPrice = ceil($price);
31
+ break;
32
+ default:
33
+ $roundedPrice = floor($price);
34
+ }
35
+ return $roundedPrice;
36
+ }
37
+
38
+ public function formatTxt($price, $options = array())
39
+ {
40
+ if (!is_numeric($price)) {
41
+ $price = Mage::app()->getLocale()->getNumber($price);
42
+ }
43
+ /**
44
+ * Fix problem with 12 000 000, 1 200 000
45
+ *
46
+ * %f - the argument is treated as a float, and presented as a floating-point number (locale aware).
47
+ * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
48
+ */
49
+ $price = sprintf("%F", $price);
50
+ $priceOutput = Mage::app()->getLocale()->currency($this->getCode())->toCurrency($price, $options);
51
+ return $priceOutput;
52
+ }
53
+ }
54
+
app/code/community/Psquared/PriceRounding/Model/RoundingMethods.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Psquared_PriceRounding_Model_RoundingMethods
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 1, 'label'=> Mage::helper('pricerounding')->__('round')),
9
+ array('value' => 2, 'label'=> Mage::helper('pricerounding')->__('ceil')),
10
+ array('value' => 3, 'label'=> Mage::helper('pricerounding')->__('floor')),
11
+ );
12
+ }
13
+ }
app/code/community/Psquared/PriceRounding/etc/config.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Psquared_PriceRounding>
5
+ <version>1.0.1</version>
6
+ </Psquared_PriceRounding>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <pricerounding>
11
+ <class>Psquared_PriceRounding_Helper</class>
12
+ </pricerounding>
13
+ </helpers>
14
+ <models>
15
+ <pricerounding>
16
+ <class>Psquared_PriceRounding_Model</class>
17
+ </pricerounding>
18
+ <directory>
19
+ <rewrite>
20
+ <currency>Psquared_PriceRounding_Model_Directory_Currency</currency>
21
+ </rewrite>
22
+ </directory>
23
+ </models>
24
+ </global>
25
+ <default>
26
+ <catalog>
27
+ <price_rounding>
28
+ <enable_price_rounding>0</enable_price_rounding>
29
+ <rounding_method>2</rounding_method>
30
+ </price_rounding>
31
+ </catalog>
32
+ </default>
33
+ <adminhtml>
34
+ <translate>
35
+ <modules>
36
+ <pricerounding>
37
+ <files>
38
+ <default>Psquared_PriceRounding.csv</default>
39
+ </files>
40
+ </pricerounding>
41
+ </modules>
42
+ </translate>
43
+ </adminhtml>
44
+ </config>
app/code/community/Psquared/PriceRounding/etc/system.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <catalog translate="label" module="pricerounding">
5
+ <groups>
6
+ <price_rounding translate="label">
7
+ <label>Price Rounding</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>420</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <enable_price_rounding translate="label">
15
+ <label>Enable Price Rounding</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>10</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ <comment>Enables price rounding to force integer prices.</comment>
23
+ </enable_price_rounding>
24
+ <rounding_method translate="label">
25
+ <label>Rounding Method</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>Psquared_PriceRounding_Model_RoundingMethods</source_model>
28
+ <sort_order>20</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <comment>See the math functions in the PHP manual for more informations.</comment>
33
+ </rounding_method>
34
+ </fields>
35
+ </price_rounding>
36
+ </groups>
37
+ </catalog>
38
+ </sections>
39
+ </config>
app/etc/modules/Psquared_PriceRounding.xml CHANGED
@@ -2,9 +2,9 @@
2
  <config>
3
  <modules>
4
  <Psquared_PriceRounding>
5
- <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.0</version>
8
  </Psquared_PriceRounding>
9
  </modules>
10
  </config>
2
  <config>
3
  <modules>
4
  <Psquared_PriceRounding>
5
+ <active>false</active>
6
  <codePool>community</codePool>
7
+ <version>1.0.1</version>
8
  </Psquared_PriceRounding>
9
  </modules>
10
  </config>
app/locale/de_DE/Psquared_PriceRounding.csv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ "Price Rounding","Preisrundung"
2
+ "Enable Price Rounding","Aktiviere Preisrundung"
3
+ "Rounding Method","Rundungsmethode"
4
+ "round","round - Mathmatisches Runden"
5
+ "ceil","ceil - Aufrunden"
6
+ "floor","floor - Abrunden"
7
+ "Enables price rounding to force integer prices.","Aktiviert die Preisrundung, um ganzzahlige Preise zu erzwingen."
8
+ "See the math functions in the PHP manual for more informations.","Lesen Sie den Abschnitt \"Mathematische Funktionen\" in der PHP-Dokumentation für weitere Informationen."
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Psquared_PriceRounding</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -10,20 +10,23 @@
10
  <description>This tiny extension allows to round the prices in the product catalog to force integer values instead of ugly decimal values. This is helpful in combination with currency convertion.&#xD;
11
  &#xD;
12
  Example: 100 &#x20AC; =&gt; USD 131.26&#xD;
 
13
  With enabled price rounding the price will be USD 131.00&#xD;
14
  &#xD;
15
  Features:&#xD;
16
  &#xD;
17
  - Enable or disable the price rounding per store view.&#xD;
18
  - Choose the rounding method per store view: round, ceil, floor (see math functions in PHP manual for more informations.)&#xD;
 
19
  &#xD;
20
  GitHub Repository:&#xD;
 
21
  https://github.com/patrickbaber/Psquared_PriceRounding</description>
22
- <notes>Magento &gt;= 1.5.x</notes>
23
  <authors><author><name>p squared</name><user>p_squared</user><email>realityfforce@yahoo.de</email></author></authors>
24
- <date>2013-04-11</date>
25
- <time>17:44:52</time>
26
- <contents><target name="magecommunity"><dir name="."><file name="Psquared" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="mageetc"><dir name="modules"><file name="Psquared_PriceRounding.xml" hash="853e6e0d3ebab74601e80cb0870da419"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
29
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Psquared_PriceRounding</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
10
  <description>This tiny extension allows to round the prices in the product catalog to force integer values instead of ugly decimal values. This is helpful in combination with currency convertion.&#xD;
11
  &#xD;
12
  Example: 100 &#x20AC; =&gt; USD 131.26&#xD;
13
+ &#xD;
14
  With enabled price rounding the price will be USD 131.00&#xD;
15
  &#xD;
16
  Features:&#xD;
17
  &#xD;
18
  - Enable or disable the price rounding per store view.&#xD;
19
  - Choose the rounding method per store view: round, ceil, floor (see math functions in PHP manual for more informations.)&#xD;
20
+ Settings under System - Configuration - Catalog - Catalog - Price Rounding.&#xD;
21
  &#xD;
22
  GitHub Repository:&#xD;
23
+ &#xD;
24
  https://github.com/patrickbaber/Psquared_PriceRounding</description>
25
+ <notes>- Fixing wrong extension path</notes>
26
  <authors><author><name>p squared</name><user>p_squared</user><email>realityfforce@yahoo.de</email></author></authors>
27
+ <date>2013-04-12</date>
28
+ <time>10:29:48</time>
29
+ <contents><target name="magecommunity"><dir name="Psquared"><dir name="PriceRounding"><dir name="Helper"><file name="Data.php" hash="1b2b96bfc80ac99393e0c2c4bffa815c"/></dir><dir name="Model"><dir name="Directory"><file name="Currency.php" hash="0963ad057f8f833ff87cd7c6e6fd04e7"/></dir><file name="RoundingMethods.php" hash="7b74bc011066b3e1100d13be3377f3af"/></dir><dir name="etc"><file name="config.xml" hash="067fa45cbe17d12e68e74ad00f9458b6"/><file name="system.xml" hash="42c5feed1875eacaaaab118edf9c99e3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Psquared_PriceRounding.xml" hash="0ee27d34dc09a883273c39d0ebe9e13b"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Psquared_PriceRounding.csv" hash="8b20629f8fa34e9477a9e21f6f90b629"/></dir></dir></target></contents>
30
  <compatible/>
31
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
32
  </package>