ajax_out_of_stock_notification - Version 1.0.1

Version Notes

Second Release. Fixed email issue.

Download this release

Release Info

Developer Bikash Kaushik
Extension ajax_out_of_stock_notification
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Grid.php CHANGED
@@ -1,5 +1,11 @@
1
  <?php
2
-
 
 
 
 
 
 
3
  class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
  {
5
  public function __construct()
@@ -41,7 +47,6 @@ class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_
41
  'index' => 'customer_type',
42
  'type' => 'options',
43
  'renderer' => 'Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Customergroup',
44
- //'filter_condition_callback' => array($this, '_filterCategoriesCondition'),
45
  ));
46
 
47
  /*$this->addColumn('product_id', array(
@@ -73,18 +78,6 @@ class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_
73
  'index' => 'created_time',
74
  ));
75
 
76
- $this->addColumn('status', array(
77
- 'header' => Mage::helper('outofstock')->__('Status'),
78
- 'align' => 'left',
79
- 'width' => '80px',
80
- 'index' => 'status',
81
- 'type' => 'options',
82
- 'options' => array(
83
- 1 => 'Waiting',
84
- 2 => 'Notified',
85
- ),
86
- ));
87
-
88
  $this->addColumn('action',
89
  array(
90
  'header' => Mage::helper('outofstock')->__('Action'),
@@ -110,14 +103,6 @@ class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_
110
  return parent::_prepareColumns();
111
  }
112
 
113
- // protected function _filterCategoriesCondition($collection, $column)
114
- // {
115
- // if (!$value = $column->getFilter()->getValue()) {
116
- // return;
117
- // }
118
- // $this->getCollection()->addFieldToFilter('customer_id', array('finset' => $value));
119
- // }
120
-
121
  protected function _prepareMassaction()
122
  {
123
  $this->setMassactionIdField('outofstock_id');
@@ -128,29 +113,12 @@ class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_
128
  'url' => $this->getUrl('*/*/massDelete'),
129
  'confirm' => Mage::helper('outofstock')->__('Are you sure?')
130
  ));
131
-
132
- $statuses = Mage::getSingleton('outofstock/status')->getOptionArray();
133
-
134
- array_unshift($statuses, array('label'=>'', 'value'=>''));
135
- $this->getMassactionBlock()->addItem('status', array(
136
- 'label'=> Mage::helper('outofstock')->__('Change status'),
137
- 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
138
- 'additional' => array(
139
- 'visibility' => array(
140
- 'name' => 'status',
141
- 'type' => 'select',
142
- 'class' => 'required-entry',
143
- 'label' => Mage::helper('outofstock')->__('Status'),
144
- 'values' => $statuses
145
- )
146
- )
147
- ));
148
  return $this;
149
  }
150
 
151
  public function getRowUrl($row)
152
  {
153
- return false;//$this->getUrl('*/*/edit', array('id' => $row->getId()));
154
  }
155
 
156
  }
1
  <?php
2
+ /**
3
+ *
4
+ * @author Bikash Kaushik
5
+ *
6
+ * @category Kaushik
7
+ * @package Kaushik_Outofstock
8
+ */
9
  class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
  {
11
  public function __construct()
47
  'index' => 'customer_type',
48
  'type' => 'options',
49
  'renderer' => 'Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Customergroup',
 
50
  ));
51
 
52
  /*$this->addColumn('product_id', array(
78
  'index' => 'created_time',
79
  ));
80
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  $this->addColumn('action',
82
  array(
83
  'header' => Mage::helper('outofstock')->__('Action'),
103
  return parent::_prepareColumns();
104
  }
105
 
 
 
 
 
 
 
 
 
106
  protected function _prepareMassaction()
107
  {
108
  $this->setMassactionIdField('outofstock_id');
113
  'url' => $this->getUrl('*/*/massDelete'),
114
  'confirm' => Mage::helper('outofstock')->__('Are you sure?')
115
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  return $this;
117
  }
118
 
119
  public function getRowUrl($row)
120
  {
121
+ return false;
122
  }
123
 
124
  }
app/code/community/Kaushik/Outofstock/Model/Observer.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Bikash Kaushik
4
+ * @category Kaushik
5
+ * @package Kaushik_Outofstock
6
+ */
7
+
8
+ class Kaushik_Outofstock_Model_Observer {
9
+ public function stockChangeItem($observer) {
10
+ $product = $observer->getEvent()->getProduct();
11
+ if ($product) {
12
+ if ($product->getStockItem()) {
13
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
14
+ $inStock = $stockItem->getIsInStock();
15
+ if($inStock >= 1) {
16
+ $model = Mage::getModel('outofstock/outofstock')->getCollection();
17
+ $model->addFieldToFilter('product_id', $product->getId());
18
+ foreach($model as $data) {
19
+ $email = $data->getEmail();
20
+ $outofstock_id = $data->getOutofstockId();
21
+ try {
22
+ $_customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId());
23
+ $_customer->loadByEmail($email);
24
+ $recepientName = $email;
25
+ $recepientemail = $email;
26
+ if($_customer->getEntityId()) {
27
+ $recepientName = $_customer->getFirstname()." ".$_customer->getLastname();
28
+ }
29
+ $sendername = Mage::getStoreConfig('trans_email/ident_general/name');
30
+ $senderemail = Mage::getStoreConfig('trans_email/ident_general/email');
31
+ $vars = Array(
32
+ 'customerName'=>$recepientName,
33
+ 'alertGrid'=>'<a href="'.$product->getProductUrl().'" >'.$product->getName().'</a> is back in stock.',
34
+ 'productName'=>$product->getName()
35
+ );
36
+ $storeId = Mage::app()->getStore()->getId();
37
+ $translate = Mage::getSingleton('core/translate');
38
+ $template_id = 'outofstock_email_productinstock';
39
+ $email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
40
+ $email_template->setSenderEmail($senderemail);
41
+ $email_template->setSenderName($sendername);
42
+ $email_template->send($recepientemail, $recepientName, $vars, $storeId);
43
+
44
+ $deleteInfo = Mage::getModel('outofstock/outofstock');
45
+ $deleteInfo->setOutofstockId($outofstock_id)->delete();
46
+ } catch(Exception $e) {
47
+ Mage::log(print_r($e->getMessage(),true), null, 'outofstockmailerror.log');
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ public function cancelOrderItem($observer) {
56
+
57
+ }
58
+ }
app/code/community/Kaushik/Outofstock/controllers/IndexController.php CHANGED
@@ -1,11 +1,17 @@
1
  <?php
 
 
 
 
 
 
2
  class Kaushik_Outofstock_IndexController extends Mage_Core_Controller_Front_Action
3
  {
4
- // public function indexAction()
5
- // {
6
- // $this->loadLayout();
7
- // $this->renderLayout();
8
- // }
9
 
10
  public function subscribeAction()
11
  {
@@ -31,6 +37,31 @@ class Kaushik_Outofstock_IndexController extends Mage_Core_Controller_Front_Acti
31
  $newmodel->save();
32
  $response['msg'] = 'You will be notified when this item is available for purchase.';
33
  $response['status'] = 'success';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  } catch(Exception $e) {
35
  $response['msg'] = $e->getMessage();
36
  $response['status'] = 'failure';
@@ -52,6 +83,30 @@ class Kaushik_Outofstock_IndexController extends Mage_Core_Controller_Front_Acti
52
  $model->walk('delete');
53
  $response['msg'] = 'Unsubscribed successfully.';
54
  $response['status'] = 'success';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  } catch(Exception $e) {
56
  $response['msg'] = $e->getMessage();
57
  $response['status'] = 'failure';
1
  <?php
2
+ /**
3
+ * @author Bikash Kaushik
4
+ * @category Kaushik
5
+ * @package Kaushik_Outofstock
6
+ */
7
+
8
  class Kaushik_Outofstock_IndexController extends Mage_Core_Controller_Front_Action
9
  {
10
+ //public function indexAction()
11
+ //{
12
+ //$this->loadLayout();
13
+ //$this->renderLayout();
14
+ //}
15
 
16
  public function subscribeAction()
17
  {
37
  $newmodel->save();
38
  $response['msg'] = 'You will be notified when this item is available for purchase.';
39
  $response['status'] = 'success';
40
+
41
+ $_product = Mage::getModel('catalog/product')->load($data['product_id']);
42
+ $_customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId());
43
+ $_customer->loadByEmail($data['email']);
44
+ $recepientName = $data['email'];
45
+ $recepientemail = $data['email'];
46
+ if($_customer->getEntityId()) {
47
+ $recepientName = $_customer->getFirstname()." ".$_customer->getLastname();
48
+ }
49
+ $sendername = Mage::getStoreConfig('trans_email/ident_general/name');
50
+ $senderemail = Mage::getStoreConfig('trans_email/ident_general/email');
51
+ $vars = Array(
52
+ 'customerName'=>$recepientName,
53
+ 'alertGrid'=>'Thank you for subscribing for '.$_product->getName().'.',
54
+ 'productName'=>$_product->getName()
55
+ );
56
+ $storeId = Mage::app()->getStore()->getId();
57
+ $translate = Mage::getSingleton('core/translate');
58
+ $template_id = 'outofstock_email_subscription';
59
+ $email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
60
+ $email_template->setSenderEmail($senderemail);
61
+ $email_template->setSenderName($sendername);
62
+ $email_template->send($recepientemail, $recepientName, $vars, $storeId);
63
+ $translate->setTranslateInline(true);
64
+
65
  } catch(Exception $e) {
66
  $response['msg'] = $e->getMessage();
67
  $response['status'] = 'failure';
83
  $model->walk('delete');
84
  $response['msg'] = 'Unsubscribed successfully.';
85
  $response['status'] = 'success';
86
+
87
+ $_product = Mage::getModel('catalog/product')->load($data['product_id']);
88
+ $_customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId());
89
+ $_customer->loadByEmail($data['email']);
90
+ $recepientName = $data['email'];
91
+ $recepientemail = $data['email'];
92
+ if($_customer->getEntityId()) {
93
+ $recepientName = $_customer->getFirstname()." ".$_customer->getLastname();
94
+ }
95
+ $sendername = Mage::getStoreConfig('trans_email/ident_general/name');
96
+ $senderemail = Mage::getStoreConfig('trans_email/ident_general/email');
97
+ $vars = Array(
98
+ 'customerName'=>$recepientName,
99
+ 'alertGrid'=>'You are successfully unsubsribed for '.$_product->getName().'.',
100
+ 'productName'=>$_product->getName()
101
+ );
102
+ $storeId = Mage::app()->getStore()->getId();
103
+ $translate = Mage::getSingleton('core/translate');
104
+ $template_id = 'outofstock_email_unsubscribe';
105
+ $email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
106
+ $email_template->setSenderEmail($senderemail);
107
+ $email_template->setSenderName($sendername);
108
+ $email_template->send($recepientemail, $recepientName, $vars, $storeId);
109
+ $translate->setTranslateInline(true);
110
  } catch(Exception $e) {
111
  $response['msg'] = $e->getMessage();
112
  $response['status'] = 'failure';
app/code/community/Kaushik/Outofstock/etc/config.xml CHANGED
@@ -1,8 +1,15 @@
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
2
  <config>
3
  <modules>
4
  <Kaushik_Outofstock>
5
- <version>1.0.0</version>
6
  </Kaushik_Outofstock>
7
  </modules>
8
  <frontend>
@@ -142,13 +149,41 @@
142
  <class>Kaushik_Outofstock_Helper</class>
143
  </outofstock>
144
  </helpers>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  <template>
146
  <email>
147
- <outofstock_email_template module="outofstock">
148
- <label>Existing User Quote Template</label>
149
- <file>outofstock/outofstock.html</file>
 
 
 
 
 
 
 
 
 
 
150
  <type>html</type>
151
- </outofstock_email_template>
152
  </email>
153
  </template>
154
  </global>
1
  <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Module configuration
5
+ *
6
+ * @author Bikash Kaushik
7
+ */
8
+ -->
9
  <config>
10
  <modules>
11
  <Kaushik_Outofstock>
12
+ <version>1.0.1</version>
13
  </Kaushik_Outofstock>
14
  </modules>
15
  <frontend>
149
  <class>Kaushik_Outofstock_Helper</class>
150
  </outofstock>
151
  </helpers>
152
+ <events>
153
+ <catalog_product_save_after>
154
+ <observers>
155
+ <outofstock_stock_item_save>
156
+ <class>outofstock/observer</class>
157
+ <method>stockChangeItem</method>
158
+ </outofstock_stock_item_save>
159
+ </observers>
160
+ </catalog_product_save_after>
161
+ <sales_order_item_cancel>
162
+ <observers>
163
+ <outofstock_order_cancel>
164
+ <class>outofstock/observer</class>
165
+ <method>cancelOrderItem</method>
166
+ </outofstock_order_cancel>
167
+ </observers>
168
+ </sales_order_item_cancel>
169
+ </events>
170
  <template>
171
  <email>
172
+ <outofstock_email_subscription module="outofstock">
173
+ <label>Stock Email Subscription</label>
174
+ <file>outofstock/subscribe.html</file>
175
+ <type>html</type>
176
+ </outofstock_email_subscription>
177
+ <outofstock_email_unsubscribe module="outofstock">
178
+ <label>Stock Email Unsubscribe</label>
179
+ <file>outofstock/unsubscribe.html</file>
180
+ <type>html</type>
181
+ </outofstock_email_unsubscribe>
182
+ <outofstock_email_productinstock module="outofstock">
183
+ <label>Stock Email for Product Back In Stock</label>
184
+ <file>outofstock/instock.html</file>
185
  <type>html</type>
186
+ </outofstock_email_productinstock>
187
  </email>
188
  </template>
189
  </global>
app/code/community/Kaushik/Outofstock/sql/outofstock_setup/{mysql4-install-1.0.0.php → mysql4-install-1.0.1.php} RENAMED
@@ -1,20 +1,21 @@
1
  <?php
2
-
 
 
 
 
 
 
3
  $installer = $this;
4
-
5
  $installer->startSetup();
6
-
7
  $installer->run("
8
-
9
  -- DROP TABLE IF EXISTS {$this->getTable('outofstock')};
10
  CREATE TABLE {$this->getTable('outofstock')} (
11
  `outofstock_id` int(11) unsigned NOT NULL auto_increment,
12
  `email` varchar(255) NOT NULL default '' COMMENT 'Customer email',
13
- `product_id` MEDIUMINT NOT NULL default '',
14
  `created_time` datetime NULL,
15
  PRIMARY KEY (`outofstock_id`)
16
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
-
18
  ");
19
-
20
  $installer->endSetup();
1
  <?php
2
+ /**
3
+ * Out of stock notification installation script
4
+ *
5
+ * @category Kaushik
6
+ * @package Kaushik_Outofstock
7
+ */
8
+
9
  $installer = $this;
 
10
  $installer->startSetup();
 
11
  $installer->run("
 
12
  -- DROP TABLE IF EXISTS {$this->getTable('outofstock')};
13
  CREATE TABLE {$this->getTable('outofstock')} (
14
  `outofstock_id` int(11) unsigned NOT NULL auto_increment,
15
  `email` varchar(255) NOT NULL default '' COMMENT 'Customer email',
16
+ `product_id` MEDIUMINT NOT NULL,
17
  `created_time` datetime NULL,
18
  PRIMARY KEY (`outofstock_id`)
19
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
20
  ");
 
21
  $installer->endSetup();
app/design/frontend/base/default/template/outofstock/mysubscription.phtml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $customer = Mage::getModel('customer/session')->getCustomer();
3
+ $email = $customer->getEmail();
4
+ $model = Mage::getModel('outofstock/outofstock')->getCollection();
5
+ $model->addFieldToFilter('email',$email);
6
+ //echo "<pre>";print_r($model->getData());
7
+ ?>
8
+ <div class="dashboard">
9
+ <div class="page-title">
10
+ <h1><?php echo $this->__('My Stock Subscription') ?></h1>
11
+ </div>
12
+ <div class="unsubscription-message"></div>
13
+ <table id="shopping-cart-table" class="data-table">
14
+ <colgroup>
15
+ <col width="1">
16
+ <col width="1">
17
+ <col width="1">
18
+ <col width="1">
19
+ </colgroup>
20
+ <thead>
21
+ <tr class="first last">
22
+ <th rowspan="1"><span class="nobr">Image</span></th>
23
+ <th rowspan="1"><span class="nobr">Product</span></th>
24
+ <th rowspan="1"><span class="nobr">Subscribed On</span></th>
25
+ <th rowspan="1">&nbsp;</th>
26
+ </tr>
27
+ </thead>
28
+ <tbody>
29
+ <?php foreach ($model as $value): ?>
30
+ <?php $product = Mage::getModel('catalog/product')->load($value->getProductId()); ?>
31
+ <tr class="first last odd pid<?php echo $value->getProductId() ?>">
32
+ <td class="product-cart-image"><div class="image"><img width="50" src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail'); ?>" alt=""></div></td>
33
+ <td class="product-cart-info"><?php echo $product->getName(); ?></td>
34
+ <td class="product-cart-price" data-rwd-label="Price"><?php echo $value->getCreatedTime(); ?></td>
35
+ <td class="a-center product-cart-remove last">
36
+ <input type="button" class="ui-button-orange" value="unsubscribe" name="unsubscribe" id="unsubscribe" onclick="unsubscribe(<?php echo $value->getProductId(); ?>)">
37
+ </td>
38
+ </tr>
39
+ <?php endforeach; ?>
40
+ </tbody>
41
+ </table>
42
+ </div>
43
+ <style type="text/css">
44
+ .data-table thead th, .data-table tbody td {
45
+ border: 1px solid silver;
46
+ }
47
+ .ui-button-orange {
48
+ color: #fff;
49
+ line-height: 21px;
50
+ padding: 0 11px;
51
+ font-size: 12px;
52
+ text-shadow: none;
53
+ background: #F27832;
54
+ background: -moz-linear-gradient(top, rgba(253,144,58,1) 0%, rgba(241,117,49,1) 50%, rgba(238,90,12,1) 50%, rgba(223,61,1,1) 100%);
55
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(253,144,58,1)), color-stop(50%,rgba(241,117,49,1)), color-stop(50%,rgba(238,90,12,1)), color-stop(100%,rgba(223,61,1,1)));
56
+ background: -webkit-linear-gradient(top, rgba(253,144,58,1) 0%,rgba(241,117,49,1) 50%,rgba(238,90,12,1) 50%,rgba(223,61,1,1) 100%);
57
+ background: -o-linear-gradient(top, rgba(253,144,58,1) 0%,rgba(241,117,49,1) 50%,rgba(238,90,12,1) 50%,rgba(223,61,1,1) 100%);
58
+ background: -ms-linear-gradient(top, rgba(253,144,58,1) 0%,rgba(241,117,49,1) 50%,rgba(238,90,12,1) 50%,rgba(223,61,1,1) 100%);
59
+ background: linear-gradient(top, rgba(253,144,58,1) 0%,rgba(241,117,49,1) 50%,rgba(238,90,12,1) 50%,rgba(223,61,1,1) 100%);
60
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fd903a', endColorstr='#df3d01',GradientType=0 );
61
+ -webkit-border-radius: 5px;
62
+ -moz-border-radius: 5px;
63
+ border-radius: 5px;
64
+ border: 1px solid #e8792d;
65
+ box-shadow: 1px 1px 3px #aaa;
66
+ }
67
+ </style>
68
+ <script type="text/javascript">
69
+ function unsubscribe(pid) {
70
+ jQuery( ".pid"+pid+" #unsubscribe" ).prop("value","unsubscribing...");
71
+ var email = '<?php echo $email ?>';
72
+ var postUrl = '<?php echo $this->getUrl() ?>outofstock/index/unsubscribe';
73
+ jQuery.post(postUrl, {email:email,product_id:pid}, function( data ) {
74
+ var obj = jQuery.parseJSON(data);
75
+ if(obj.status == "success") {
76
+ jQuery( ".unsubscription-message" ).html('<ul class="messages"><li class="success-msg"><ul><li style="color:#14595c"><span>'+obj.msg+'</span></li></ul></li></ul>');
77
+ jQuery( ".unsubscription-message" ).fadeIn();
78
+ jQuery( ".pid"+pid ).remove();
79
+ } else if(obj.status == "failure"){
80
+ jQuery( ".unsubscription-message" ).html('<ul class="messages"><li class="error-msg"><ul><li style="color:#14595c"><span>'+obj.msg+'</span></li></ul></li></ul>');
81
+ jQuery( ".unsubscription-message" ).fadeIn();
82
+ }
83
+ setTimeout( function() {
84
+ jQuery( ".unsubscription-message" ).fadeOut();
85
+ }, 4000);
86
+ });
87
+ }
88
+ </script>
app/design/frontend/base/default/template/outofstock/outofstock.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(Mage::registry('current_product')->getStockItem()->getIsInStock()==0): ?>
2
+ <div class="login-message"></div>
3
+ <?php
4
+ $productId = Mage::registry('current_product')->getId();
5
+ if(Mage::getSingleton('customer/session')->isLoggedIn()):
6
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
7
+ $model = Mage::getModel('outofstock/outofstock')->getCollection();
8
+ $model->addFieldToFilter('email',$customer->getEmail());
9
+ $model->addFieldToFilter('product_id', $productId);
10
+ if($model->count()):
11
+ ?>
12
+ <div class="subscribed-message">
13
+ <ul class="messages"><li class="success-msg"><ul><li style="color:#14595c"><span>You are subscribed for availability of this product.</span></li></ul></li></ul>
14
+ </div>
15
+ <?php else: ?>
16
+ <div class="outofstock-notify">
17
+ <div class="input-box">
18
+ <input type="hidden" name="product_id" id="product_id" value="<?php echo $productId ?>">
19
+ <input type="hidden" style="width: 265px;" autocapitalize="off" autocorrect="off" spellcheck="false" name="notify-email" value="<?php echo $customer->getEmail() ?>" id="notify-email" class="input-text required-entry validate-email" title="Email Address" />
20
+ <button type="submit" class="button" title="Notify me" name="subscribe" id="subscribe"><span><span>Notify me</span></span></button>
21
+ </div>
22
+ </div>
23
+ <?php endif; ?>
24
+ <?php else: ?>
25
+ <div class="outofstock-notify">
26
+ <div class="input-box">
27
+ <input type="hidden" name="product_id" id="product_id" value="<?php echo $productId ?>">
28
+ <input type="email" style="width: 265px;" autocapitalize="off" autocorrect="off" spellcheck="false" name="notify-email" value="" id="notify-email" class="input-text required-entry validate-email" title="Email Address" />
29
+ <button type="submit" class="button" title="Notify me" name="subscribe" id="subscribe"><span><span>Notify me</span></span></button>
30
+ </div>
31
+ </div>
32
+ <?php endif; ?>
33
+ <script type="text/javascript">
34
+ jQuery('.outofstock-notify .button').click(function(e){
35
+ e.preventDefault();
36
+ jQuery(this).addClass('disabled');
37
+ var email = jQuery("#notify-email").val();
38
+ var product_id = jQuery("#product_id").val();
39
+ var postUrl = '<?php echo $this->getUrl() ?>outofstock/index/subscribe';
40
+ jQuery.post(postUrl, {email:email,product_id:product_id}, function( data ) {
41
+ var obj = jQuery.parseJSON(data);
42
+ if(obj.status == "success") {
43
+ jQuery( ".login-message" ).html('<ul class="messages"><li class="success-msg"><ul><li style="color:#14595c"><span>'+obj.msg+'</span></li></ul></li></ul>');
44
+ jQuery( ".login-message" ).fadeIn();
45
+ jQuery(".outofstock-notify").hide();
46
+ } else if(obj.status == "failure"){
47
+ jQuery( ".login-message" ).html('<ul class="messages"><li class="error-msg"><ul><li style="color:#14595c"><span>'+obj.msg+'</span></li></ul></li></ul>');
48
+ jQuery( ".login-message" ).fadeIn();
49
+ jQuery("#subscribe").removeClass('disabled');
50
+ } else if(obj.status == "warning"){
51
+ jQuery( ".login-message" ).html('<ul class="messages"><li class="error-msg"><ul><li style="color:#14595c"><span>'+obj.msg+'</span></li></ul></li></ul>');
52
+ jQuery( ".login-message" ).fadeIn();
53
+ jQuery("#subscribe").removeClass('disabled');
54
+ }
55
+ setTimeout( function() {
56
+ jQuery( ".login-message" ).fadeOut();
57
+ }, 4000);
58
+ });
59
+ });
60
+ </script>
61
+ <?php endif; ?>
app/locale/en_US/template/email/outofstock/instock.html ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject {{var productName}} is back in stock. @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "store url=\"customer/account/\"":"Customer Account Url"}
6
+ @-->
7
+
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
13
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
15
+ <tr>
16
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
17
+ <!-- [ header starts here] -->
18
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <tr>
20
+ <td valign="top">
21
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+ <tr>
25
+ <td valign="top">
26
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{var customerName}},</h1>
27
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">{{var alertGrid}}<p>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
33
+ </tr>
34
+ </table>
35
+ </td>
36
+ </tr>
37
+ </table>
38
+ </div>
39
+ </body>
app/locale/en_US/template/email/outofstock/subscribe.html ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Subscribed successfully for {{var productName}} @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "store url=\"customer/account/\"":"Customer Account Url"}
6
+ @-->
7
+
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
13
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
15
+ <tr>
16
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
17
+ <!-- [ header starts here] -->
18
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <tr>
20
+ <td valign="top">
21
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+ <tr>
25
+ <td valign="top">
26
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{var customerName}},</h1>
27
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">{{var alertGrid}} Login your account to view your subscription details.<p>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
33
+ </tr>
34
+ </table>
35
+ </td>
36
+ </tr>
37
+ </table>
38
+ </div>
39
+ </body>
app/locale/en_US/template/email/outofstock/unsubscribe.html ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Unsubscribed successfully for {{var productName}} @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "store url=\"customer/account/\"":"Customer Account Url"}
6
+ @-->
7
+
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
13
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
15
+ <tr>
16
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
17
+ <!-- [ header starts here] -->
18
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <tr>
20
+ <td valign="top">
21
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+ <tr>
25
+ <td valign="top">
26
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{var customerName}},</h1>
27
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">{{var alertGrid}}<p>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
33
+ </tr>
34
+ </table>
35
+ </td>
36
+ </tr>
37
+ </table>
38
+ </div>
39
+ </body>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ajax_out_of_stock_notification</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension allows both customers and guest to sign up for alerts once out of stock products are available.</summary>
10
- <description>This extension adds a Notify button into product detail page for out of stock products. By clicking on this button, registered members &amp; guests can enter their email to receive notifications when products are in stock. When admin adds new inventory for a product and it becomes in stock, the system will send an email notification to customers who subscribed to that product. This extension helps store owners in inventory decision making about out of stock products based on subscriptions.</description>
11
- <notes>First Release.</notes>
12
  <authors><author><name>Bikash Kaushik</name><user>bikashkaushik</user><email>bikashkaushik10@gmail.com</email></author></authors>
13
- <date>2017-01-05</date>
14
- <time>06:17:25</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Kaushik_Outofstock.xml" hash="fd1e66f8a5bead211c2ea44092facfce"/></dir></target><target name="magecommunity"><dir name="Kaushik"><dir name="Outofstock"><dir name="Block"><dir name="Adminhtml"><dir name="Outofstock"><file name="Grid.php" hash="c005078b83898a6a530e9707e963660e"/><dir name="Renderer"><file name="Customergroup.php" hash="6f61885eb9edf31d11bf63c377ef163b"/><file name="Productname.php" hash="075b88440a10ad72feb9feaa1cb02b3a"/><file name="Productsku.php" hash="055505ace7ea75e3af4eabc27a09192d"/></dir></dir><file name="Outofstock.php" hash="7da318da3c745ce52a0b136fdd3b2d1f"/></dir><file name="Outofstock.php" hash="61d61ac94f1effb50fa605a3b3ffc015"/></dir><dir name="Helper"><file name="Data.php" hash="300e095c1c92671fdc9b33b900f6f282"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="de5c63ffe094e4fc1941431b93bc366b"/></dir><dir name="Mysql4"><dir name="Outofstock"><file name="Collection.php" hash="c679943ae9ead796676f0b9cb5aeb708"/></dir><file name="Outofstock.php" hash="4d2a337d37c11b174d8652adf05c96f8"/></dir><file name="Outofstock.php" hash="585524ff6b1de528db940ec27591f60d"/><file name="Status.php" hash="6aca3bcdebce0753f5853f5fe4b009ca"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OutofstockController.php" hash="b1f10282d4ceaf5bd30e960a591c831a"/></dir><file name="IndexController.php" hash="62673cf4afe4d4ce88018a5daa107dae"/></dir><dir name="etc"><file name="adminhtml.xml" hash="72760cb708ffcc195e12a75a40e94f16"/><file name="config.xml" hash="5c665f4b357dbd67e1e383cddc9863e5"/><file name="system.xml" hash="8e9b17fe5cedbbb222c345f0784454ec"/></dir><dir name="sql"><dir name="outofstock_setup"><file name="mysql4-install-1.0.0.php" hash="a0e891081ddb04fb8eefd4a083ff6ac7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="outofstock.xml" hash="8f11e51d42ac271810d0a891ec8a0bce"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="kaushik_outofstock.xml" hash="8d2c38a2d84647ee0822f8c1e762ad70"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>7.1.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ajax_out_of_stock_notification</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension allows both customers and guest to sign up for alerts once out of stock products are available.</summary>
10
+ <description>This extension adds a Notify button into product detail page for out of stock products. By clicking on this button, registered members &amp;amp; guests can enter their email to receive notifications when products are in stock. When admin adds new inventory for a product and it becomes in stock, the system will send an email notification to customers who subscribed to that product. This extension helps store owners in inventory decision making about out of stock products based on subscriptions.</description>
11
+ <notes>Second Release. Fixed email issue.</notes>
12
  <authors><author><name>Bikash Kaushik</name><user>bikashkaushik</user><email>bikashkaushik10@gmail.com</email></author></authors>
13
+ <date>2017-01-18</date>
14
+ <time>07:00:28</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Kaushik_Outofstock.xml" hash="fd1e66f8a5bead211c2ea44092facfce"/></dir></target><target name="magecommunity"><dir name="Kaushik"><dir name="Outofstock"><dir name="Block"><dir name="Adminhtml"><dir name="Outofstock"><file name="Grid.php" hash="0cb37482f3468997788e40fe60283717"/><dir name="Renderer"><file name="Customergroup.php" hash="6f61885eb9edf31d11bf63c377ef163b"/><file name="Productname.php" hash="075b88440a10ad72feb9feaa1cb02b3a"/><file name="Productsku.php" hash="055505ace7ea75e3af4eabc27a09192d"/></dir></dir><file name="Outofstock.php" hash="7da318da3c745ce52a0b136fdd3b2d1f"/></dir><file name="Outofstock.php" hash="61d61ac94f1effb50fa605a3b3ffc015"/></dir><dir name="Helper"><file name="Data.php" hash="300e095c1c92671fdc9b33b900f6f282"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="de5c63ffe094e4fc1941431b93bc366b"/></dir><dir name="Mysql4"><dir name="Outofstock"><file name="Collection.php" hash="c679943ae9ead796676f0b9cb5aeb708"/></dir><file name="Outofstock.php" hash="4d2a337d37c11b174d8652adf05c96f8"/></dir><file name="Observer.php" hash="a49dbe6e15adccb921d2a087edbcad8d"/><file name="Outofstock.php" hash="585524ff6b1de528db940ec27591f60d"/><file name="Status.php" hash="6aca3bcdebce0753f5853f5fe4b009ca"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OutofstockController.php" hash="b1f10282d4ceaf5bd30e960a591c831a"/></dir><file name="IndexController.php" hash="8a860480ac5d9a03587a94b24a1fffc6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="72760cb708ffcc195e12a75a40e94f16"/><file name="config.xml" hash="d753a06b9500cee54c55a98cf7d93bdf"/><file name="system.xml" hash="8e9b17fe5cedbbb222c345f0784454ec"/></dir><dir name="sql"><dir name="outofstock_setup"><file name="mysql4-install-1.0.1.php" hash="940075c23934ec1ff7f86b26b1dc908d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="outofstock.xml" hash="8f11e51d42ac271810d0a891ec8a0bce"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="kaushik_outofstock.xml" hash="8d2c38a2d84647ee0822f8c1e762ad70"/></dir><dir name="template"><dir name="outofstock"><file name="mysubscription.phtml" hash="6c1cd3fd0eee3ca659876ffe0a2fb944"/><file name="outofstock.phtml" hash="8c5bbe2115f32f0e68ef064bc5e762fb"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="outofstock"><file name="instock.html" hash="2e2bc8eeea4c88fff55300605f0bce53"/><file name="subscribe.html" hash="59f04c27a8b6c25f675caed58778a99e"/><file name="unsubscribe.html" hash="a500cd1e6a8c238cf225dccae6b1c037"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>7.1.0</max></php></required></dependencies>
18
  </package>