Ayaline_MaxAmount - Version 1.1.0

Version Notes

aYaline MaxAmount allow to define a max amount for orders.

Download this release

Release Info

Developer Magento Core Team
Extension Ayaline_MaxAmount
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/community/Ayaline/MaxAmount/Helper/Data.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * created : 11/04/2012
4
+ *
5
+ * @category Ayaline
6
+ * @package Ayaline_MaxAmount
7
+ * @author aYaline
8
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
9
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
10
+ */
11
+
12
+ /**
13
+ *
14
+ * @package Ayaline_MaxAmount
15
+ */
16
+ class Ayaline_MaxAmount_Helper_Data extends Mage_Core_Helper_Abstract {
17
+
18
+ const XML_MAXAMOUNT_CART_ENABLE = 'ayalinemaxamount/cart/enable';
19
+ const XML_MAXAMOUNT_CART_MAXAMOUNT = 'ayalinemaxamount/cart/maxamount';
20
+ const XML_MAXAMOUNT_CART_MESSAGE = 'ayalinemaxamount/cart/message';
21
+
22
+ const XML_MAXAMOUNT_PRODUCT_ENABLE = 'ayalinemaxamount/product/enable';
23
+ const XML_MAXAMOUNT_PRODUCT_MESSAGE = 'ayalinemaxamount/product/message';
24
+
25
+ /* CONFIGURATIONS */
26
+
27
+ /**
28
+ * Check cart max amount is enabled
29
+ *
30
+ * @param mixed $store
31
+ * @return bool
32
+ */
33
+ public function isCartEnable($store = null) {
34
+ return Mage::getStoreConfig(self::XML_MAXAMOUNT_CART_ENABLE, $store);
35
+ }
36
+
37
+ /**
38
+ * Check if product max amount is enabled
39
+ *
40
+ * @param mixed $store
41
+ * @return bool
42
+ */
43
+ public function isProductEnable($store = null) {
44
+ if($this->isCartEnable($store)) {
45
+ return Mage::getStoreConfig(self::XML_MAXAMOUNT_PRODUCT_ENABLE, $store);
46
+ }
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * Retrieve cart max amount
52
+ *
53
+ * @param mixed $store
54
+ * @return float
55
+ */
56
+ public function getCartMaxAmount($store = null) {
57
+ return Mage::getStoreConfig(self::XML_MAXAMOUNT_CART_MAXAMOUNT, $store);
58
+ }
59
+
60
+ /**
61
+ * Retrieve cart message
62
+ *
63
+ * @param mixed $store
64
+ * @return string
65
+ */
66
+ public function getCartMessage($store = null) {
67
+ return Mage::getStoreConfig(self::XML_MAXAMOUNT_CART_MESSAGE, $store);
68
+ }
69
+
70
+ /**
71
+ * Retrieve product view message
72
+ *
73
+ * @param mixed $store
74
+ * @return string
75
+ */
76
+ public function getProductMessage($store = null) {
77
+ return Mage::getStoreConfig(self::XML_MAXAMOUNT_PRODUCT_MESSAGE, $store);
78
+ }
79
+
80
+ /**
81
+ * Check max amount on cart
82
+ *
83
+ * @param Mage_Sales_Model_Quote $quote
84
+ */
85
+ public function checkCartMaxAmount($quote) {
86
+ $quoteStore = $quote->getStore();
87
+ if($this->isCartEnable($quoteStore)) {
88
+ $maxAmount = $this->getCartMaxAmount($quoteStore);
89
+ $grandTotal = $quote->getGrandTotal();
90
+ if($grandTotal > $maxAmount) {
91
+ $formater = new Varien_Filter_Template();
92
+ $formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false)));
93
+ $format = $this->getCartMessage($quoteStore);
94
+ // hold checkout
95
+ $quote->setHasError(true)->addMessage($formater->filter($format));
96
+ }
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Check max amount after adding product to cart
102
+ *
103
+ * @param Mage_Sales_Model_Quote_Item $quoteItem
104
+ */
105
+ public function checkProductmaxAmount($quoteItem){
106
+ $quoteStore = $quoteItem->getStore();
107
+ if($this->isProductEnable($quoteStore)) {
108
+ $maxAmount = $this->getCartMaxAmount($quoteStore);
109
+ /* @var $quote Mage_Sales_Model_Quote */
110
+ $quote = $quoteItem->getQuote();
111
+ $grandTotal = $quote->getGrandTotal();
112
+ $grandTotal += $quoteItem->getProduct()->getFinalPrice($quoteItem->getQty());
113
+ if($grandTotal > $maxAmount){
114
+ $formater = new Varien_Filter_Template();
115
+ $formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false)));
116
+ $format = $this->getProductMessage($quoteStore);
117
+ // throw exception for "remove" product to cart
118
+ Mage::throwException($formater->filter($format));
119
+ }
120
+ }
121
+ }
122
+ }
app/code/community/Ayaline/MaxAmount/Model/Observer.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * created : 11/04/2012
4
+ *
5
+ * @category Ayaline
6
+ * @package Ayaline_MaxAmount
7
+ * @author aYaline
8
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
9
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
10
+ */
11
+
12
+ /**
13
+ *
14
+ * @package Ayaline_MaxAmount
15
+ */
16
+ class Ayaline_MaxAmount_Model_Observer {
17
+
18
+ /**
19
+ * Check if cart amount is greater than the "max amount" allowed (on cart)
20
+ *
21
+ * @param Varien_Event_Observer $observer
22
+ * @return Ayaline_MaxAmount_Model_Observer
23
+ */
24
+ public function checkCartMaxAmount(Varien_Event_Observer $observer) {
25
+ /* @var $event Varien_Event */
26
+ $event = $observer->getEvent();
27
+ /* @var $quote Mage_Sales_Model_Quote */
28
+ $quote = $event->getQuote();
29
+ Mage::helper('ayalinemaxamount')->checkCartMaxAmount($quote);
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Check if cart amount is greater than the "max amount" allowed (before add product)
35
+ *
36
+ * @param Varien_Event_Observer $observer
37
+ * @return Ayaline_MaxAmount_Model_Observer
38
+ */
39
+ public function checkProductMaxAmount(Varien_Event_Observer $observer) {
40
+ /* @var $event Varien_Event */
41
+ $event = $observer->getEvent();
42
+ /* @var $quoteItem Mage_Sales_Model_Quote_Item */
43
+ $quoteItem = $event->getQuoteItem();
44
+ Mage::helper('ayalinemaxamount')->checkProductMaxAmount($quoteItem);
45
+ return $this;
46
+ }
47
+
48
+
49
+ }
app/code/community/Ayaline/MaxAmount/etc/adminhtml.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * created : 11/04/2012
5
+ *
6
+ * @category Ayaline
7
+ * @package Ayaline_MaxAmount
8
+ * @author aYaline
9
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
10
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
11
+ */
12
+ -->
13
+ <config>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+ <system>
19
+ <children>
20
+ <config>
21
+ <children>
22
+ <ayalinemaxamount translate="title" module="ayalinemaxamount">
23
+ <title>Ayaline Order Max Amount</title>
24
+ </ayalinemaxamount>
25
+ </children>
26
+ </config>
27
+ </children>
28
+ </system>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
+ </config>
app/code/community/Ayaline/MaxAmount/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * created : 11/04/2012
5
+ *
6
+ * @category Ayaline
7
+ * @package Ayaline_MaxAmount
8
+ * @author aYaline
9
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
10
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
11
+ */
12
+ -->
13
+ <config>
14
+
15
+ <modules>
16
+ <Ayaline_MaxAmount>
17
+ <version>1.1</version>
18
+ </Ayaline_MaxAmount>
19
+ </modules>
20
+
21
+ <global>
22
+ <helpers>
23
+ <ayalinemaxamount>
24
+ <class>Ayaline_MaxAmount_Helper</class>
25
+ </ayalinemaxamount>
26
+ </helpers>
27
+ <models>
28
+ <ayalinemaxamount>
29
+ <class>Ayaline_MaxAmount_Model</class>
30
+ </ayalinemaxamount>
31
+ </models>
32
+ </global>
33
+
34
+ <frontend>
35
+ <translate>
36
+ <modules>
37
+ <Ayaline_MaxAmount>
38
+ <files>
39
+ <default>Ayaline_MaxAmount.csv</default>
40
+ </files>
41
+ </Ayaline_MaxAmount>
42
+ </modules>
43
+ </translate>
44
+ <events>
45
+ <sales_quote_load_after>
46
+ <observers>
47
+ <ayalinemaxamount_check_maxamount>
48
+ <class>ayalinemaxamount/observer</class>
49
+ <method>checkCartMaxAmount</method>
50
+ </ayalinemaxamount_check_maxamount>
51
+ </observers>
52
+ </sales_quote_load_after>
53
+ <checkout_cart_product_add_after>
54
+ <observers>
55
+ <ayalinemaxamount_check_maxamount>
56
+ <class>ayalinemaxamount/observer</class>
57
+ <method>checkProductMaxAmount</method>
58
+ </ayalinemaxamount_check_maxamount>
59
+ </observers>
60
+ </checkout_cart_product_add_after>
61
+ </events>
62
+ </frontend>
63
+
64
+ <adminhtml>
65
+ <translate>
66
+ <modules>
67
+ <Ayaline_MaxAmount>
68
+ <files>
69
+ <default>Ayaline_MaxAmount.csv</default>
70
+ </files>
71
+ </Ayaline_MaxAmount>
72
+ </modules>
73
+ </translate>
74
+ </adminhtml>
75
+
76
+ </config>
app/code/community/Ayaline/MaxAmount/etc/system.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * created : 11/04/2012
5
+ *
6
+ * @category Ayaline
7
+ * @package Ayaline_MaxAmount
8
+ * @author aYaline
9
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
10
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
11
+ */
12
+ -->
13
+ <config>
14
+ <sections>
15
+ <ayalinemaxamount translate="label" module="ayalinemaxamount">
16
+ <label>Order Max Amount</label>
17
+ <tab>ayaline</tab>
18
+ <header_css>ayaline-header</header_css>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>200</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <groups>
25
+ <cart translate="label" module="ayalinemaxamount">
26
+ <label>On Cart</label>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>10</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
+ <fields>
33
+ <enable translate="label" module="ayalinemaxamount">
34
+ <label>Enable Max Amount</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <sort_order>10</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ </enable>
42
+ <maxamount translate="label" module="ayalinemaxamount">
43
+ <label>Max Amount Allow In Cart</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>20</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <depends><enable>1</enable></depends>
50
+ </maxamount>
51
+ <message translate="label" module="ayalinemaxamount">
52
+ <label>Information Message</label>
53
+ <frontend_type>textarea</frontend_type>
54
+ <sort_order>40</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <depends><enable>1</enable></depends>
59
+ <tooltip>You can use the keyword {{var amount}}, it will be replaced by the amount entered previously.</tooltip>
60
+ </message>
61
+ </fields>
62
+ </cart>
63
+ <product translate="label" module="ayalinemaxamount">
64
+ <label>On Product</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>20</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <fields>
71
+ <enable translate="label comment tooltip" module="ayalinemaxamount">
72
+ <label>Enable Max Amount</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>adminhtml/system_config_source_yesno</source_model>
75
+ <sort_order>10</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <comment>If the option is activated, the check will be made before the addition in the cart</comment>
80
+ <tooltip><![CDATA[<span style="color: red; font-weight: bold;">Attention</span> This feature will be activated only if <em style="white-space: nowrap;">"On Cart"</em> is enabled.]]></tooltip>
81
+ </enable>
82
+ <message translate="label" module="ayalinemaxamount">
83
+ <label>Information Message</label>
84
+ <frontend_type>textarea</frontend_type>
85
+ <sort_order>20</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <depends><enable>1</enable></depends>
90
+ <tooltip>You can use the keyword {{var amount}}, it will be replaced by the amount entered previously.</tooltip>
91
+ </message>
92
+ </fields>
93
+ </product>
94
+ </groups>
95
+ </ayalinemaxamount>
96
+ </sections>
97
+ </config>
app/etc/modules/Ayaline_MaxAmount.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * created : 11/04/2012
5
+ *
6
+ * @category Ayaline
7
+ * @package Ayaline_MaxAmount
8
+ * @author aYaline
9
+ * @copyright Ayaline - 2012 - http://magento-shop.ayaline.com
10
+ * @license http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Ayaline_MaxAmount>
16
+ <active>true</active>
17
+ <codePool>community</codePool>
18
+ <depends><Ayaline_Core /></depends>
19
+ </Ayaline_MaxAmount>
20
+ </modules>
21
+ </config>
app/locale/en_US/Ayaline_MaxAmount.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ "Order Max Amount","Order Max Amount"
2
+ "On Cart","On Cart"
3
+ "Enable Max Amount","Enable Max Amount"
4
+ "Information Message","Information Message"
5
+ "On Product","On Product"
6
+ "If the option is activated, the check will be made before the addition in the cart","If the option is activated, the check will be made before the addition in the cart"
7
+ "Max Amount Allow In Cart","Max Amount Allow In Cart"
8
+ "<span style=""color: red; font-weight: bold;"">Attention</span> This feature will be activated only if <em style=""white-space: nowrap;"">""On Cart""</em> is enabled.","<span style=""color: red; font-weight: bold;"">Attention</span> This feature will be activated only if <em style=""white-space: nowrap;"">""On Cart""</em> is enabled."
9
+ "You can use the keyword {{var amount}}, it will be replaced by the amount entered previously.","You can use the keyword {{var amount}}, it will be replaced by the amount entered previously."
10
+ "Ayaline Order Max Amount","Ayaline Order Max Amount"
app/locale/fr_FR/Ayaline_MaxAmount.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ "Order Max Amount","Montant Maxi d'une commande"
2
+ "On Cart","Sur le panier"
3
+ "Enable Max Amount","Activer le montant maxi"
4
+ "Information Message","Message d'information"
5
+ "On Product","Sur le produit"
6
+ "If the option is activated, the check will be made before the addition in the cart","Si l'option est activée, la vérification sera faite avant l'ajout dans le panier."
7
+ "Max Amount Allow In Cart","Montant maxi dans le panier"
8
+ "<span style=""color: red; font-weight: bold;"">Attention</span> This feature will be activated only if <em style=""white-space: nowrap;"">""On Cart""</em> is enabled.","<span style=""color: red; font-weight: bold;"">Attention</span> Cette fonctionnalité sera activée uniquement si <em style=""white-space: nowrap;"">""Sur le panier""</em> est activée."
9
+ "You can use the keyword {{var amount}}, it will be replaced by the amount entered previously.","Vous pouvez utiliser le mot clé {{var amount}}, il sera remplacé par le montant saisi précédement."
10
+ "Ayaline Order Max Amount","Ayaline Montant Maxi d'une commande"
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ayaline_MaxAmount</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://magento-shop.ayaline.com/fr/conditions-generales-de-vente.html">aYaline Custom License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>aYaline MaxAmount allow to define a max amount for orders.</summary>
10
+ <description>Secure your online selling activity with Ayaline MaxAmount.&#xD;
11
+ This extension prevents to validate an order if it&#x2019;s amount is greater than the threshold you define.&#xD;
12
+ &#xD;
13
+ Order amount verification is done at two levels :&#xD;
14
+ - on the product page, before the product is added to the cart&#xD;
15
+ - on the cart to prevent access to the processing tunnel&#xD;
16
+ When the threshold is crossed, customer is warnedd by a customizable informative message</description>
17
+ <notes>aYaline MaxAmount allow to define a max amount for orders.</notes>
18
+ <authors><author><name>aYaline Team</name><user>auto-converted</user><email>magento@ayaline.com</email></author></authors>
19
+ <date>2012-03-23</date>
20
+ <time>10:02:22</time>
21
+ <contents><target name="magecommunity"><dir name="Ayaline"><dir name="MaxAmount"><dir name="Helper"><file name="Data.php" hash="9fccc737539026e7903808e4a517de6f"/></dir><dir name="Model"><file name="Observer.php" hash="04c7d9dcb460642a7dc2d352c1ac52c4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2d1cac38962288c0e0a1f6f31a419f3f"/><file name="config.xml" hash="2213e63b6f60863da254ddc9a49428dd"/><file name="system.xml" hash="bd49750161c6728d7735c74d6ee05921"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ayaline_MaxAmount.xml" hash="9374659a90b2c71318985916e0eaab59"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Ayaline_MaxAmount.csv" hash="3a19fae489c20afb782160f5ab7d97f5"/></dir><dir name="fr_FR"><file name="Ayaline_MaxAmount.csv" hash="84b0b4ded9b56dc2b0e4e3746c269525"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><package><name>Ayaline_Core</name><channel>community</channel><min></min><max></max></package></required></dependencies>
24
+ </package>