This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.xml
252 lines (237 loc) · 11.5 KB
/
install.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Product Requests</name>
<code>product_requests_v101</code>
<description>Improve customer retention by allowing requests for backordered products; automated notifications when the item restocks.</description>
<version>1.0.1</version>
<author>Angela</author>
<link>https://github.com/angela-d</link>
<file path="admin/controller/common/login.php">
<operation error="skip" info="Check for unconfirmed requests greater than 7 days and purge them.">
<search ><![CDATA[
$this->session->data['token'] = token(32);
]]></search>
<add position="before"><![CDATA[
$this->load->model('report/product_request');
$this->model_report_product_request->purgeCheck();
]]></add>
</operation>
</file>
<file path="admin/language/*/extension/dashboard/activity.php">
<operation error="skip" info="Language reference for the recent activity feed.">
<search ><![CDATA[
$_['text_customer_order_guest'] = '%s created a <a href="order_id=%d">new order</a>.';
]]></search>
<add position="after"><![CDATA[
$_['text_customer_notify'] = '<a href="product_id=%s">%s</a> requested updates on the %s';
]]></add>
</operation>
</file>
<file path="admin/controller/extension/dashboard/activity.php">
<operation error="skip" info="Link the recent activity feed to the product requested.">
<search ><![CDATA[
'order_id=',
]]></search>
<add position="after"><![CDATA[
'product_id=',
]]></add>
</operation>
<operation error="skip" info="Write the link.">
<search ><![CDATA[
$this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=', true),
]]></search>
<add position="after"><![CDATA[
$this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=', true),
]]></add>
</operation>
</file>
<file path="admin/model/catalog/product.php">
<operation error="skip" info="If a product is deleted, delete all open requests, too.">
<search ><![CDATA[
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
]]></search>
<add position="after"><![CDATA[
$this->db->query("DELETE FROM " . DB_PREFIX . "product_notification WHERE product_id = '" . (int)$product_id . "'");
]]></add>
</operation>
</file>
<file path="admin/language/en-gb/common/column_left.php">
<operation error="skip" info="English language reference to reports tab for Product Requests.">
<search ><![CDATA[
$_['text_reports'] = 'Reports';
]]></search>
<add position="before"><![CDATA[
$_['text_product_requests'] = 'Product Requests';
]]></add>
</operation>
</file>
<file path="admin/controller/common/column_left.php">
<operation error="skip" info="Adds a link to all requests under the Reports tab.">
<search ><![CDATA[
if ($report) {
]]></search>
<add position="before"><![CDATA[
if ($this->user->hasPermission('access', 'report/product_request') && $this->config->get('product_request_status')) {
$report[] = array(
'name' => $this->language->get('text_product_requests'),
'href' => $this->url->link('report/product_request', 'token=' . $this->session->data['token'], true),
'children' => array()
);
}
]]></add>
</operation>
</file>
<file path="admin/controller/catalog/product.php">
<operation error="skip" info="Adds a call to notify the customer if the item is available for purchase; upon the item being added back in stock.">
<search ><![CDATA[
$this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);
]]></search>
<add position="after"><![CDATA[
$this->load->model('report/product_request');
if (isset($this->request->post['quantity']) && $this->request->post['quantity'] >0 && $this->config->get('product_request_status')) {
$product_request = $this->model_report_product_request->checkRequests($this->request->get['product_id']);
if ($product_request >0){
$email_requests = $this->model_report_product_request->sendNotifications($this->request->get['product_id']);
}
}
]]></add>
</operation>
<operation error="skip" info="See if any requests exist for this product and display a note to the admin if any are found.">
<search ><![CDATA[
if (isset($this->request->post['product_description'])) {
]]></search>
<add position="before"><![CDATA[
$this->load->model('report/product_request');
$this->load->language('report/product_request');
if ($this->config->get('product_request_status')){
$check_notification_reqs = isset($this->request->get['product_id']) ? $this->model_report_product_request->checkRequests($this->request->get['product_id']) : '';
$data['notification_reqs'] = $check_notification_reqs;
$data['text_banner'] = sprintf($this->language->get('text_banner'),$check_notification_reqs);
}
]]></add>
</operation>
</file>
<file path="admin/view/template/catalog/product_form.tpl">
<operation error="skip" info="Displays a banner if this product has customers awaiting a stock notification.">
<search ><![CDATA[
<div id="content">
<div class="page-header">
<div class="container-fluid">
]]></search>
<add position="after"><![CDATA[
<?php
if ($notification_reqs >0){
echo'<div class="alert alert-danger">'.sprintf($text_banner,$notification_reqs).'</div>';
}
?>
]]></add>
</operation>
</file>
<file path="catalog/controller/product/product.php">
<operation error="skip" info="Adds a language file pull for the Product Request extension.">
<search ><![CDATA[
$this->load->language('product/product');
]]></search>
<add position="before"><![CDATA[
$data['product_request_criteria'] = $this->config->get('product_request_criteria');
$this->load->language('extension/module/product_request');
$data['text_banner_signup'] = $this->language->get('text_banner_signup');
$data['button_notify'] = $this->language->get('button_notify');
]]></add>
</operation>
<operation error="skip" info="Function to process a customer signup request.">
<search ><![CDATA[
public function write() {
]]></search>
<add position="before"><![CDATA[
public function notifier() {
$this->load->language('extension/module/product_request');
$json = array();
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if ((utf8_strlen($this->request->post['notify']) < 9) || (utf8_strlen($this->request->post['notify']) > 75) ||($this->request->post['notify'] =='email@example.com') || !filter_var($this->request->post['notify'], FILTER_VALIDATE_EMAIL)) {
$json['error'] = $this->language->get('error_email');
}
if (!empty($this->request->post['email'])) {
$json['error'] = $this->language->get('error_honeypot');
}
if (!isset($json['error'])) {
$this->load->model('extension/module/product_request');
$this->model_extension_module_product_request->addNotifier($this->request->get['product_id'], $this->request->post, $this->session->data['language']);
$json['success'] = $this->language->get('text_notify_success');
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
]]></add>
</operation>
<operation error="skip" info="Converts the stock status from lingual to numeric to allow multi-language capability.">
<search ><![CDATA[
$this->load->model('tool/image');
]]></search>
<add position="before"><![CDATA[
$this->load->model('extension/module/product_request');
$data['stock_status_total'] = $this->model_extension_module_product_request->getStatus($data['stock']);
]]></add>
</operation>
</file>
<file path="catalog/view/theme/*/template/product/product.tpl">
<operation error="skip" info="A condition to switch the add to cart button with a requests box when an item is unavailable.">
<search ><![CDATA[
<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
]]></search>
<add position="before"><![CDATA[
<?php if (!$stock_status_total){ ?>
]]></add>
</operation>
<operation error="skip" info="Adds the product request signup to the product template.">
<search ><![CDATA[
<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
]]></search>
<add position="after"><![CDATA[
<?php }else{ ?>
<div id="product-notify">
<?php echo $text_banner_signup; ?>
<form class="form-horizontal" id="form-notify">
<input type="text" name="notify" placeholder="email@example.com" id="input-notify" class="form-control" />
<input type="hidden" name="email" value="" id="input-email" class="form-control" />
<button type="button" id="button-notify" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-default"><?php echo $button_notify; ?></button>
</form>
</div>
<?php } ?>
]]></add>
</operation>
<operation error="skip" info="jQuery to process the form data on the template.">
<search ><![CDATA[
$('#button-cart').on('click', function() {
]]></search>
<add position="before"><![CDATA[
$('#button-notify').on('click', function() {
$.ajax({
url: 'index.php?route=product/product/notifier&product_id=<?php echo $product_id; ?>',
type: 'post',
dataType: 'json',
data: $("#form-notify").serialize(),
beforeSend: function() {
$('#button-notify').button('loading');
},
complete: function() {
$('#button-notify').button('reset');
},
success: function(json) {
$('.alert-success, .alert-danger').remove();
if (json['error']) {
$('#product-notify').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
}
if (json['success']) {
$('#product-notify').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');
$('input[name=\'notify\']').val('');
$('input[name=\'email\']').val('');
}
}
});
});
]]></add>
</operation>
</file>
</modification>