Order_approval - Version 0.4.1.0

Version Notes

* Add backward support for Magento 1.6 and earlier releases\
* Small bug fixes and improvements

Download this release

Release Info

Developer Anatoly A. Kazantsev
Extension Order_approval
Version 0.4.1.0
Comparing to
See all releases


Code changes from version 0.4.0.0 to 0.4.1.0

app/code/community/ZetaPrints/OrderApproval/Model/Events/Observer.php CHANGED
@@ -46,7 +46,7 @@ class ZetaPrints_OrderApproval_Model_Events_Observer {
46
  //only not approved items for futher processing.
47
 
48
  //For every item from the quote check...
49
- foreach ($quote->getAllVisibleItems(true) as $item)
50
  //... if it's approved then...
51
  if ($item->getApproved())
52
  //...remove it from the cart
@@ -329,7 +329,14 @@ class ZetaPrints_OrderApproval_Model_Events_Observer {
329
  if (count($quote->getItemsCollection())
330
  == count($items_to_approve)) {
331
  //... redirect to shopping cart page
332
- $controller->setRedirectWithCookieCheck('checkout/cart');
 
 
 
 
 
 
 
333
 
334
  return;
335
  }
46
  //only not approved items for futher processing.
47
 
48
  //For every item from the quote check...
49
+ foreach ($quote->getAllVisibleItems() as $item)
50
  //... if it's approved then...
51
  if ($item->getApproved())
52
  //...remove it from the cart
329
  if (count($quote->getItemsCollection())
330
  == count($items_to_approve)) {
331
  //... redirect to shopping cart page
332
+
333
+ //Add support for Magento < 1.7
334
+ if (method_exists($controller, 'setRedirectWithCookieCheck'))
335
+ $controller->setRedirectWithCookieCheck('checkout/cart');
336
+ else
337
+ $controller
338
+ ->getResponse()
339
+ ->setRedirect(Mage::getUrl('checkout/cart'));
340
 
341
  return;
342
  }
app/code/community/ZetaPrints/OrderApproval/Model/Quote.php CHANGED
@@ -53,6 +53,22 @@ class ZetaPrints_OrderApproval_Model_Quote extends Mage_Sales_Model_Quote {
53
  ? parent::setIsActive($active)
54
  : $this;
55
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  ?>
53
  ? parent::setIsActive($active)
54
  : $this;
55
  }
56
+
57
+ /**
58
+ * Retrieve quote items collection
59
+ *
60
+ * NOTE: the method adds backward compatibility
61
+ * with Magento < 1.7
62
+ *
63
+ * @param bool $useCache
64
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
65
+ */
66
+ public function getItemsCollection($useCache = true) {
67
+ if ($this->hasItemsCollection())
68
+ return $this->getData('items_collection');
69
+
70
+ return parent::getItemsCollection($useCache);
71
+ }
72
  }
73
 
74
  ?>
app/code/community/ZetaPrints/OrderApproval/controllers/CustomercartController.php CHANGED
@@ -62,7 +62,7 @@ class ZetaPrints_OrderApproval_CustomerCartController
62
  ->loadByCustomer($customer_id);
63
 
64
  if (!$quote->getId()) {
65
- $this->_redirect('');
66
 
67
  return;
68
  }
@@ -186,6 +186,19 @@ class ZetaPrints_OrderApproval_CustomerCartController
186
 
187
  $item->setOptions($optionCollection->getOptionsByItem($item));
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  $emails = array($customer->getEmail());
190
  $names = array($customer->getName());
191
 
@@ -204,18 +217,19 @@ class ZetaPrints_OrderApproval_CustomerCartController
204
  ->addNotice($this->__('Product was declined'));
205
  }
206
 
207
- Mage::getModel('core/email_template')
208
- ->sendTransactional(
209
- $template,
210
- 'sales',
211
- $emails,
212
- $names,
213
- array(
214
- 'items' => array($item),
215
- 'number_of_items' => 1,
216
- 'customer' => $customer,
217
- )
218
- );
 
219
 
220
  $this->_redirect('*/*/edit', array('customer' => $quote->getCustomerId()));
221
  }
@@ -298,6 +312,19 @@ class ZetaPrints_OrderApproval_CustomerCartController
298
  $items[] = $item;
299
  }
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  if ($state == ZetaPrints_OrderApproval_Helper_Data::APPROVED) {
302
  $template = Mage::getStoreConfig(self::XML_APPROVED_TEMPLATE);
303
 
@@ -313,18 +340,19 @@ class ZetaPrints_OrderApproval_CustomerCartController
313
  ->addNotice($this->__('Selected products were declined'));
314
  }
315
 
316
- Mage::getModel('core/email_template')
317
- ->sendTransactional(
318
- $template,
319
- 'sales',
320
- $emails,
321
- $names,
322
- array(
323
- 'items' => $items,
324
- 'number_of_items' => count($items),
325
- 'customer' => $customer,
326
- )
327
- );
 
328
 
329
  $this->_redirect('*/*/edit', array('customer' => $quote->getCustomerId()));
330
  }
62
  ->loadByCustomer($customer_id);
63
 
64
  if (!$quote->getId()) {
65
+ $this->_redirect('orderapproval/customercart/all');
66
 
67
  return;
68
  }
186
 
187
  $item->setOptions($optionCollection->getOptionsByItem($item));
188
 
189
+ $settings = new Varien_Object(array(
190
+ 'email_notification' => true
191
+ ));
192
+
193
+ Mage::dispatchEvent(
194
+ 'orderapproval_quote_state_updated',
195
+ array(
196
+ 'quote' => $quote,
197
+ 'state' => $state,
198
+ 'settings' => $settings
199
+ )
200
+ );
201
+
202
  $emails = array($customer->getEmail());
203
  $names = array($customer->getName());
204
 
217
  ->addNotice($this->__('Product was declined'));
218
  }
219
 
220
+ if ($settings->getData('email_notification'))
221
+ Mage::getModel('core/email_template')
222
+ ->sendTransactional(
223
+ $template,
224
+ 'sales',
225
+ $emails,
226
+ $names,
227
+ array(
228
+ 'items' => array($item),
229
+ 'number_of_items' => 1,
230
+ 'customer' => $customer,
231
+ )
232
+ );
233
 
234
  $this->_redirect('*/*/edit', array('customer' => $quote->getCustomerId()));
235
  }
312
  $items[] = $item;
313
  }
314
 
315
+ $settings = new Varien_Object(array(
316
+ 'email_notification' => true
317
+ ));
318
+
319
+ Mage::dispatchEvent(
320
+ 'orderapproval_quote_state_updated',
321
+ array(
322
+ 'quote' => $quote,
323
+ 'state' => $state,
324
+ 'settings' => $settings
325
+ )
326
+ );
327
+
328
  if ($state == ZetaPrints_OrderApproval_Helper_Data::APPROVED) {
329
  $template = Mage::getStoreConfig(self::XML_APPROVED_TEMPLATE);
330
 
340
  ->addNotice($this->__('Selected products were declined'));
341
  }
342
 
343
+ if ($settings->getData('email_notification'))
344
+ Mage::getModel('core/email_template')
345
+ ->sendTransactional(
346
+ $template,
347
+ 'sales',
348
+ $emails,
349
+ $names,
350
+ array(
351
+ 'items' => $items,
352
+ 'number_of_items' => count($items),
353
+ 'customer' => $customer,
354
+ )
355
+ );
356
 
357
  $this->_redirect('*/*/edit', array('customer' => $quote->getCustomerId()));
358
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Order_approval</name>
4
- <version>0.4.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -24,14 +24,12 @@ The approver can log in, view the list of items and then either approve or&#xD;
24
  cancel the purchase.&#xD;
25
  &#xD;
26
  Users without a nominated approver can check out as usual.</description>
27
- <notes>* New implementation (issue #813)&#xD;
28
- * Add support for order creation via admin inteface&#xD;
29
- * Allow to set approver per customer group (issue #812)&#xD;
30
- * Send notification emails to customer (issue #330)</notes>
31
- <authors><author><name>Anatoly A. Kazantsev</name><user>jimcrow</user><email>anatoly.kazantsev@gmail.com</email></author></authors>
32
- <date>2013-04-02</date>
33
- <time>19:29:49</time>
34
- <contents><target name="mageetc"><dir name="modules"><file name="ZetaPrints_OrderApproval.xml" hash="5ee48ca83fdb3610c659d6a9e4d2e027"/></dir></target><target name="magecommunity"><dir name="ZetaPrints"><dir name="OrderApproval"><dir name="Block"><dir name="Customercart"><dir name="Edit"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Abstract.php" hash="36cf6a845ec51140ba219d3d74aab6d9"/><file name="Image.php" hash="9e9d90fc91a3ab6e7a09f8e91732f7c8"/><file name="Price.php" hash="51fe87a6aaa99e783eaafe5acf5c6286"/><file name="Productoptions.php" hash="5323448e054b6ac27780558c78bcfe15"/><file name="Qty.php" hash="009857ec32aae2ffbf63f1946c49d104"/><file name="Subtotal.php" hash="2ab57a194db635119d63104c04a48139"/></dir></dir></dir><file name="Grid.php" hash="c86a99fc1a4664ed8ba33d072affa59a"/></dir><file name="Edit.php" hash="9b386d9afc94d1efe2cf33aa8a67058c"/><file name="Item.php" hash="4f929b8f21b30247bcb3a4b335b2af2a"/></dir><file name="Customercart.php" hash="427b8e13430c1a992cc1191a44a229e0"/></dir><dir name="Helper"><file name="Data.php" hash="610297515e9a82854931c6b847eea73e"/></dir><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Approvers.php" hash="afa73cdcf25ad5feeb6f6eca3f036ca5"/></dir></dir></dir><dir name="Events"><file name="Observer.php" hash="fdf9c655eab2d8677c9988bb467a1f98"/></dir><file name="Quote.php" hash="f61302aa2f19f2f501b608dd74462215"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Admins.php" hash="a95bce3314aafb7997434b03fa400389"/></dir></dir></dir></dir><dir name="controllers"><file name="CustomercartController.php" hash="61f8db95cbcfe3b54f5735ea7dccc176"/></dir><dir name="data"><dir name="orderapproval_setup"><file name="data-upgrade-2-3.php" hash="dbd1420d7518a2722b0584638610e4be"/></dir></dir><dir name="etc"><file name="config.xml" hash="c50bab9c0ee8e8b375f71f0bae1ff7eb"/><file name="system.xml" hash="1524e066af4ae39b7b4ab984c89c2264"/></dir><dir name="sql"><dir name="orderapproval_setup"><file name="mysql4-data-upgrade-1-2.php" hash="e51e107f343a4c31bd9fe2b12afb855a"/><file name="mysql4-install-1.php" hash="2ed307cae48c5d639ba5cfcbb3a4ad44"/><file name="upgrade-2-3.php" hash="b37238d5590f1206cbe0c90e4fc94bee"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="orderapproval"><file name="approved_items.html" hash="0e6d600f5f2c0dec5af90e47e0b9c1f5"/><file name="declined_items.html" hash="d72e51f7ddb3501e5c07b79a2f0970f3"/><file name="items_to_approve.html" hash="ecaaf635d93eb95139b52edc825411ce"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="order-approval"><dir><dir name="cart"><dir name="edit"><dir name="grid"><dir name="column"><dir name="renderer"><file name="image.phtml" hash="eb90230daaba6696b09d00d53967d6a2"/><file name="price.phtml" hash="f47bc098cbe31f40861b89744f76a8a6"/><file name="product-options.phtml" hash="de73952675681ad5d66bebd8878a7295"/><file name="qty.phtml" hash="efa017d34741b02b72d8f962ee7704af"/><file name="subtotal.phtml" hash="6bdd910cc427f4f0bd30dcf869d2b1da"/></dir></dir></dir></dir><file name="edit.phtml" hash="1a6ac3ef492885f1e9d828284c48e28e"/><dir name="item"><file name="customer_info.phtml" hash="f89251d5b85a12935035f5158436eb18"/></dir><file name="item.phtml" hash="126f38ae97f9c5340a17e0ea0a134302"/></dir></dir><file name="cart.phtml" hash="25bb08c2c3a7692454b05df9ffad47a9"/></dir><dir name="widget"><dir><dir name="grid"><file name="container.phtml" hash="3eac12f7df27bdfeb2115467e8c03120"/><file name="massaction.phtml" hash="c1c2350057d49aa434939c79c3565567"/></dir></dir><file name="grid.phtml" hash="6c81f87e9c6fd9db99ffe88f8220357c"/></dir><dir name="email"><dir name="orderapproval"><file name="item.phtml" hash="0293fb78798fca32ce700992d76d1a0d"/><file name="items.phtml" hash="2af569531af93ed829f2b78a981f26bb"/></dir></dir></dir><dir name="layout"><file name="order-approval.xml" hash="b981473db04e0a206ea19df6a65dcb1f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="order-approval"><file name="styles.css" hash="ea6d3b28888a140bf44fe38c9b5a34c6"/></dir></dir></dir></dir></dir></target></contents>
35
  <compatible/>
36
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
37
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Order_approval</name>
4
+ <version>0.4.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
24
  cancel the purchase.&#xD;
25
  &#xD;
26
  Users without a nominated approver can check out as usual.</description>
27
+ <notes>* Add backward support for Magento 1.6 and earlier releases\&#xD;
28
+ * Small bug fixes and improvements</notes>
29
+ <authors><author><name>Anatoly A. Kazantsev</name><user>jimcrow</user><email>anatoly@zetaprints.com</email></author></authors>
30
+ <date>2013-09-10</date>
31
+ <time>05:24:32</time>
32
+ <contents><target name="mageetc"><dir name="modules"><file name="ZetaPrints_OrderApproval.xml" hash="5ee48ca83fdb3610c659d6a9e4d2e027"/></dir></target><target name="magecommunity"><dir name="ZetaPrints"><dir name="OrderApproval"><dir name="Block"><dir name="Customercart"><dir name="Edit"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Abstract.php" hash="36cf6a845ec51140ba219d3d74aab6d9"/><file name="Image.php" hash="9e9d90fc91a3ab6e7a09f8e91732f7c8"/><file name="Price.php" hash="51fe87a6aaa99e783eaafe5acf5c6286"/><file name="Productoptions.php" hash="5323448e054b6ac27780558c78bcfe15"/><file name="Qty.php" hash="009857ec32aae2ffbf63f1946c49d104"/><file name="Subtotal.php" hash="2ab57a194db635119d63104c04a48139"/></dir></dir></dir><file name="Grid.php" hash="c86a99fc1a4664ed8ba33d072affa59a"/></dir><file name="Edit.php" hash="9b386d9afc94d1efe2cf33aa8a67058c"/><file name="Item.php" hash="4f929b8f21b30247bcb3a4b335b2af2a"/></dir><file name="Customercart.php" hash="427b8e13430c1a992cc1191a44a229e0"/></dir><dir name="Helper"><file name="Data.php" hash="610297515e9a82854931c6b847eea73e"/></dir><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Approvers.php" hash="afa73cdcf25ad5feeb6f6eca3f036ca5"/></dir></dir></dir><dir name="Events"><file name="Observer.php" hash="7649a2c8157a366eab70e73de3008bb9"/></dir><file name="Quote.php" hash="956e20d4f579cccff593075ce19a3064"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Admins.php" hash="a95bce3314aafb7997434b03fa400389"/></dir></dir></dir></dir><dir name="controllers"><file name="CustomercartController.php" hash="d80036dfe7c8c64378a90844bca59e95"/></dir><dir name="data"><dir name="orderapproval_setup"><file name="data-upgrade-2-3.php" hash="dbd1420d7518a2722b0584638610e4be"/></dir></dir><dir name="etc"><file name="config.xml" hash="c50bab9c0ee8e8b375f71f0bae1ff7eb"/><file name="system.xml" hash="1524e066af4ae39b7b4ab984c89c2264"/></dir><dir name="sql"><dir name="orderapproval_setup"><file name="mysql4-data-upgrade-1-2.php" hash="e51e107f343a4c31bd9fe2b12afb855a"/><file name="mysql4-install-1.php" hash="2ed307cae48c5d639ba5cfcbb3a4ad44"/><file name="upgrade-2-3.php" hash="b37238d5590f1206cbe0c90e4fc94bee"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="orderapproval"><file name="approved_items.html" hash="0e6d600f5f2c0dec5af90e47e0b9c1f5"/><file name="declined_items.html" hash="d72e51f7ddb3501e5c07b79a2f0970f3"/><file name="items_to_approve.html" hash="ecaaf635d93eb95139b52edc825411ce"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="order-approval"><dir><dir name="cart"><dir name="edit"><dir name="grid"><dir name="column"><dir name="renderer"><file name="image.phtml" hash="eb90230daaba6696b09d00d53967d6a2"/><file name="price.phtml" hash="f47bc098cbe31f40861b89744f76a8a6"/><file name="product-options.phtml" hash="de73952675681ad5d66bebd8878a7295"/><file name="qty.phtml" hash="efa017d34741b02b72d8f962ee7704af"/><file name="subtotal.phtml" hash="6bdd910cc427f4f0bd30dcf869d2b1da"/></dir></dir></dir></dir><file name="edit.phtml" hash="1a6ac3ef492885f1e9d828284c48e28e"/><dir name="item"><file name="customer_info.phtml" hash="f89251d5b85a12935035f5158436eb18"/></dir><file name="item.phtml" hash="126f38ae97f9c5340a17e0ea0a134302"/></dir></dir><file name="cart.phtml" hash="25bb08c2c3a7692454b05df9ffad47a9"/></dir><dir name="widget"><dir><dir name="grid"><file name="container.phtml" hash="3eac12f7df27bdfeb2115467e8c03120"/><file name="massaction.phtml" hash="c1c2350057d49aa434939c79c3565567"/></dir></dir><file name="grid.phtml" hash="6c81f87e9c6fd9db99ffe88f8220357c"/></dir><dir name="email"><dir name="orderapproval"><file name="item.phtml" hash="0293fb78798fca32ce700992d76d1a0d"/><file name="items.phtml" hash="2af569531af93ed829f2b78a981f26bb"/></dir></dir></dir><dir name="layout"><file name="order-approval.xml" hash="b981473db04e0a206ea19df6a65dcb1f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="order-approval"><file name="styles.css" hash="ea6d3b28888a140bf44fe38c9b5a34c6"/></dir></dir></dir></dir></dir></target></contents>
 
 
33
  <compatible/>
34
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
35
  </package>