Version Notes
Features:
- This release adds the ability to disable the PriceWaiter widget by Customer Group.
Download this release
Release Info
Developer | PriceWaiter |
Extension | nypwidget |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.7 to 1.3.0
- app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php +6 -3
- app/code/community/PriceWaiter/NYPWidget/Block/Category.php +37 -35
- app/code/community/PriceWaiter/NYPWidget/Block/Widget.php +3 -1
- app/code/community/PriceWaiter/NYPWidget/Helper/Data.php +205 -191
- app/code/community/PriceWaiter/NYPWidget/Model/Callback.php +318 -314
- app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php +15 -13
- app/code/community/PriceWaiter/NYPWidget/Model/Category.php +65 -63
- app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php +4 -2
- app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php +4 -2
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php +7 -5
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php +8 -6
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php +7 -5
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php +7 -5
- app/code/community/PriceWaiter/NYPWidget/Model/Observer.php +26 -24
- app/code/community/PriceWaiter/NYPWidget/Model/Order.php +20 -18
- app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php +17 -16
- app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php +4 -2
- app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php +3 -1
- app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml +1 -1
- app/code/community/PriceWaiter/NYPWidget/etc/config.xml +32 -28
- app/code/community/PriceWaiter/NYPWidget/etc/system.xml +37 -4
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php +1 -1
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php +21 -21
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php +1 -1
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.2.4-1.2.5.php +1 -1
- app/design/adminhtml/default/default/layout/pricewaiter.xml +11 -5
- app/design/adminhtml/default/default/template/pricewaiter/admin_widget.phtml +10 -10
- app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml +27 -27
- app/design/frontend/base/default/layout/pricewaiter.xml +7 -5
- app/design/frontend/base/default/template/pricewaiter/widget.phtml +19 -18
- app/etc/modules/PriceWaiter_NYPWidget.xml +3 -3
- js/pricewaiter/product-pages.js +258 -258
- package.xml +148 -11
- skin/adminhtml/default/default/pricewaiter.css +17 -17
app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,9 +16,11 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Abstract
|
19 |
{
|
20 |
-
public function _getHelper()
|
|
|
21 |
$helper = Mage::helper('nypwidget');
|
22 |
return $helper;
|
23 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Abstract
|
21 |
{
|
22 |
+
public function _getHelper()
|
23 |
+
{
|
24 |
$helper = Mage::helper('nypwidget');
|
25 |
return $helper;
|
26 |
}
|
app/code/community/PriceWaiter/NYPWidget/Block/Category.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,40 +16,41 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Block_Category extends Mage_Adminhtml_Block_Template
|
19 |
-
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
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 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Block_Category extends Mage_Adminhtml_Block_Template
|
21 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
22 |
{
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
$this->setTemplate('pricewaiter/categorytab.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getIsEnabled()
|
29 |
+
{
|
30 |
+
$category = Mage::registry('category');
|
31 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category, $category->getStore()->getId());
|
32 |
+
|
33 |
+
return $nypcategory->isActive(true);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getTabLabel()
|
37 |
+
{
|
38 |
+
return $this->__('PriceWaiter Widget');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getTabTitle()
|
42 |
+
{
|
43 |
+
return $this->__('PriceWaiter');
|
44 |
+
}
|
45 |
+
|
46 |
+
public function canShowTab()
|
47 |
+
{
|
48 |
+
return true;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function isHidden()
|
52 |
+
{
|
53 |
+
return false;
|
54 |
+
}
|
55 |
|
56 |
}
|
app/code/community/PriceWaiter/NYPWidget/Block/Widget.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,6 +16,7 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Block_Widget extends Mage_Core_Block_Template
|
19 |
{
|
20 |
public function _getHelper()
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Block_Widget extends Mage_Core_Block_Template
|
21 |
{
|
22 |
public function _getHelper()
|
app/code/community/PriceWaiter/NYPWidget/Helper/Data.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
-
* Copyright 2013 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
@@ -19,180 +19,194 @@
|
|
19 |
|
20 |
class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
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 |
var PriceWaiterOptions = {
|
89 |
apiKey: '" . $apiKey . "',
|
90 |
button: {
|
91 |
type: " . json_encode($displayPhrase) . ",
|
92 |
size: " . json_encode($displaySize) . ",";
|
93 |
|
94 |
-
|
95 |
-
|
96 |
color: " . json_encode($displayColor) . ",";
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
hoverColor: " . json_encode($displayHoverColor) . ",";
|
102 |
-
|
103 |
|
104 |
-
|
105 |
},
|
106 |
};\n";
|
107 |
|
108 |
-
|
109 |
-
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
115 |
sku: 'TEST-SKU',
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
123 |
|
124 |
-
|
125 |
|
126 |
-
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
var PriceWaiterProductType = 'simple';
|
132 |
";
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
var PriceWaiterProductType = 'configurable';
|
137 |
";
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
var PriceWaiterProductType = 'grouped';\n"
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
var PriceWaiterProductType = 'bundle';
|
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 |
PriceWaiterOptions.product = {
|
197 |
sku: " . json_encode($product->getSku()) . ",
|
198 |
name: " . json_encode($product->getName()) . ",
|
@@ -200,45 +214,45 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
|
200 |
image: " . json_encode($product->getImageUrl()) . "
|
201 |
};
|
202 |
var PriceWaiterRegularPrice = '" . (float)$product->getPrice() . "';
|
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 |
}
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
19 |
|
20 |
class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
21 |
{
|
22 |
+
private $_product = false;
|
23 |
+
private $_testing = false;
|
24 |
+
|
25 |
+
public function isTesting()
|
26 |
+
{
|
27 |
+
return $this->_testing;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function isEnabled()
|
31 |
+
{
|
32 |
+
// Is the pricewaiter widget enabled for this store
|
33 |
+
if (Mage::getStoreConfig('pricewaiter/configuration/enabled')) {
|
34 |
+
|
35 |
+
// Is the pricewaiter widget enabled for this product
|
36 |
+
$product = $this->_getProduct();
|
37 |
+
if (!is_object($product) or ($product->getId() and $product->getData('nypwidget_disabled'))) {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
|
41 |
+
// Is the PriceWaiter widget enabled for this category
|
42 |
+
$category = Mage::registry('current_category');
|
43 |
+
if (is_object($category)) {
|
44 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category);
|
45 |
+
if (!$nypcategory->isActive()) {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
} else {
|
49 |
+
// We end up here if we are visiting the product page without being
|
50 |
+
// "in a category". Basically, we arrived via a search page.
|
51 |
+
// The logic here checks to see if there are any categories that this
|
52 |
+
// product belongs to that enable the PriceWaiter widget. If not, return false.
|
53 |
+
$categories = $product->getCategoryIds();
|
54 |
+
$categoryActive = false;
|
55 |
+
foreach ($categories as $categoryId) {
|
56 |
+
unset($currentCategory);
|
57 |
+
unset($nypcategory);
|
58 |
+
$currentCategory = Mage::getModel('catalog/category')->load($categoryId);
|
59 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($currentCategory);
|
60 |
+
if ($nypcategory->isActive()) {
|
61 |
+
$categoryActive = true;
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
if (!$categoryActive) {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
// Is PriceWaiter enabled for this Customer Group
|
71 |
+
$disable = Mage::getStoreConfig('pricewaiter/customer_groups/disable');
|
72 |
+
if ($disable) {
|
73 |
+
// An admin has chosen to disable the PriceWaiter widget by customer group.
|
74 |
+
$customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
75 |
+
$customerGroups = Mage::getStoreConfig('pricewaiter/customer_groups/group_select');
|
76 |
+
$customerGroups = preg_split('/,/', $customerGroups);
|
77 |
+
|
78 |
+
if (in_array($customerGroupId, $customerGroups)) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
// We end up here if PriceWaiter is disabled for this store
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
return true;
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getPriceWaiterOptions()
|
91 |
+
{
|
92 |
+
$apiKey = Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
93 |
+
|
94 |
+
$displayPhrase = Mage::getStoreConfig('pricewaiter/appearance/display_phrase') ? 'button_mo' : 'button_nyp';
|
95 |
+
$displaySize = Mage::getStoreConfig('pricewaiter/appearance/display_size') ? 'sm' : 'lg';
|
96 |
+
$displayColor = Mage::getStoreConfig('pricewaiter/appearance/display_color');
|
97 |
+
$displayHoverColor = Mage::getStoreConfig('pricewaiter/appearance/display_hover_color');
|
98 |
+
|
99 |
+
$pwOptions = "
|
100 |
var PriceWaiterOptions = {
|
101 |
apiKey: '" . $apiKey . "',
|
102 |
button: {
|
103 |
type: " . json_encode($displayPhrase) . ",
|
104 |
size: " . json_encode($displaySize) . ",";
|
105 |
|
106 |
+
if ($displayColor) {
|
107 |
+
$pwOptions .= "
|
108 |
color: " . json_encode($displayColor) . ",";
|
109 |
+
}
|
110 |
|
111 |
+
if ($displayHoverColor) {
|
112 |
+
$pwOptions .= "
|
113 |
hoverColor: " . json_encode($displayHoverColor) . ",";
|
114 |
+
}
|
115 |
|
116 |
+
$pwOptions .= "
|
117 |
},
|
118 |
};\n";
|
119 |
|
120 |
+
return $pwOptions;
|
121 |
+
}
|
122 |
|
123 |
+
public function getProductOptions($admin = false)
|
124 |
+
{
|
125 |
+
if ($admin) {
|
126 |
+
return "
|
127 |
+
PriceWaiterOptions.product = {
|
128 |
sku: 'TEST-SKU',
|
129 |
+
name: 'Test Name',
|
130 |
+
price: 19.99,
|
131 |
+
image: 'http://placekitten.com/220/220'
|
132 |
+
};
|
133 |
+
var PriceWaiterProductType = 'simple';
|
134 |
+
var PriceWaiterRegularPrice = 19.99
|
135 |
+
";
|
136 |
+
}
|
137 |
|
138 |
+
$product = $this->_getProduct();
|
139 |
|
140 |
+
if ($product->getId()) {
|
141 |
|
142 |
+
switch ($product->getTypeId()) {
|
143 |
+
case "simple":
|
144 |
+
return $this->_pwBoilerPlate($product) . "
|
145 |
var PriceWaiterProductType = 'simple';
|
146 |
";
|
147 |
+
break;
|
148 |
+
case "configurable":
|
149 |
+
return $this->_pwBoilerPlate($product) . "
|
150 |
var PriceWaiterProductType = 'configurable';
|
151 |
";
|
152 |
+
break;
|
153 |
+
case "grouped":
|
154 |
+
return $this->_pwBoilerPlate($product) . "
|
155 |
var PriceWaiterProductType = 'grouped';\n"
|
156 |
+
. $this->_getGroupedProductInfo() . "\n";
|
157 |
+
break;
|
158 |
+
case "virtual":
|
159 |
+
// Virtual products are not yet supported
|
160 |
+
return false;
|
161 |
+
break;
|
162 |
+
case "bundle":
|
163 |
+
return $this->_pwBoilerPlate($product) . "
|
164 |
var PriceWaiterProductType = 'bundle';
|
165 |
";
|
166 |
+
break;
|
167 |
+
case "downloadable":
|
168 |
+
// Downloadable products are not yet supported
|
169 |
+
return false;
|
170 |
+
break;
|
171 |
+
default:
|
172 |
+
return false;
|
173 |
+
break;
|
174 |
+
}
|
175 |
+
} else {
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getWidgetUrl()
|
181 |
+
{
|
182 |
+
if ($this->_testing) {
|
183 |
+
return "https://widget-staging.pricewaiter.com/nyp/script/widget.js";
|
184 |
+
} else {
|
185 |
+
return "https://widget.pricewaiter.com/nyp/script/widget.js";
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
public function getApiUrl()
|
190 |
+
{
|
191 |
+
if ($this->_testing) {
|
192 |
+
return "https://api-staging.pricewaiter.com/1/order/verify?"
|
193 |
+
. "api_key="
|
194 |
+
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
195 |
+
} else {
|
196 |
+
return "https://api.pricewaiter.com/1/order/verify?api_key="
|
197 |
+
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
private function _pwBoilerPlate($product)
|
202 |
+
{
|
203 |
+
if ($product->getTypeId() == 'grouped') {
|
204 |
+
$productPrice = 0;
|
205 |
+
} else {
|
206 |
+
$productPrice = $product->getFinalPrice();
|
207 |
+
}
|
208 |
+
|
209 |
+
return "
|
210 |
PriceWaiterOptions.product = {
|
211 |
sku: " . json_encode($product->getSku()) . ",
|
212 |
name: " . json_encode($product->getName()) . ",
|
214 |
image: " . json_encode($product->getImageUrl()) . "
|
215 |
};
|
216 |
var PriceWaiterRegularPrice = '" . (float)$product->getPrice() . "';
|
217 |
+
";
|
218 |
+
}
|
219 |
+
|
220 |
+
private function _getProduct()
|
221 |
+
{
|
222 |
+
if (!$this->_product) {
|
223 |
+
$this->_product = Mage::registry('current_product');
|
224 |
+
}
|
225 |
+
|
226 |
+
return $this->_product;
|
227 |
+
}
|
228 |
+
|
229 |
+
private function _getGroupedProductInfo()
|
230 |
+
{
|
231 |
+
$product = $this->_getProduct();
|
232 |
+
$javascript = "var PriceWaiterGroupedProductInfo = new Array();\n";
|
233 |
+
|
234 |
+
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
235 |
+
foreach ($associatedProducts as $simpleProduct) {
|
236 |
+
$javascript .= "PriceWaiterGroupedProductInfo[" . $simpleProduct->getId() . "] = ";
|
237 |
+
$javascript .= "new Array('" . htmlentities($simpleProduct->getName()) . "', '"
|
238 |
+
. number_format($simpleProduct->getPrice(), 2) . "')\n";
|
239 |
+
}
|
240 |
+
|
241 |
+
return $javascript;
|
242 |
+
}
|
243 |
+
|
244 |
+
public function getStoreByApiKey($apiKey)
|
245 |
+
{
|
246 |
+
$stores = Mage::app()->getStores();
|
247 |
+
|
248 |
+
// Find the store with the matching API key by checking the key for each store
|
249 |
+
// in Magento
|
250 |
+
foreach ($stores as $store) {
|
251 |
+
if ($apiKey == Mage::getStoreConfig('pricewaiter/configuration/api_key', $store->getId())) {
|
252 |
+
return $store;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
return Mage::app()->getStore();
|
257 |
+
}
|
258 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Callback.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,320 +16,323 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Callback
|
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 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
334 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Callback
|
21 |
{
|
22 |
|
23 |
+
private $_store;
|
24 |
+
private $_groupId = '1';
|
25 |
+
private $_sendConfirmation = '0';
|
26 |
+
|
27 |
+
private $orderData = array();
|
28 |
+
private $_product;
|
29 |
+
|
30 |
+
private $_sourceCustomer;
|
31 |
+
private $_sourceOrder;
|
32 |
+
|
33 |
+
public function processRequest($request)
|
34 |
+
{
|
35 |
+
// If the PriceWaiter extension is in testing mode, skip request validation
|
36 |
+
if (!Mage::helper('nypwidget')->isTesting()) {
|
37 |
+
// Build URL to check validity of order notification.
|
38 |
+
$url = Mage::helper('nypwidget')->getApiUrl();
|
39 |
+
|
40 |
+
$ch = curl_init($url);
|
41 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
42 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
43 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
44 |
+
|
45 |
+
// If PriceWaiter returns an invalid response
|
46 |
+
if (curl_exec($ch) == "1") {
|
47 |
+
$message = "The Name Your Price Widget has received a valid order notification.";
|
48 |
+
Mage::log($message);
|
49 |
+
$this->_log($message);
|
50 |
+
} else {
|
51 |
+
$message = "An invalid PriceWaiter order notification has been received.";
|
52 |
+
Mage::log($message);
|
53 |
+
$this->_log($message);
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
// Verify that we have not already received this callback based on the `pricewaiter_id` field
|
59 |
+
$pricewaiterOrder = Mage::getModel('nypwidget/order');
|
60 |
+
$pricewaiterOrder->loadByPriceWaiterId($request['pricewaiter_id']);
|
61 |
+
if ($pricewaiterOrder->getId()) {
|
62 |
+
$message = "Received a duplicate order from the PriceWaiter Callback API. Ignoring.";
|
63 |
+
$this->_log($message);
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
try {
|
68 |
+
|
69 |
+
// First, determine the store that this order corresponds to.
|
70 |
+
// This is a new feature as of 1.2.2, so we need to make sure the API
|
71 |
+
// is compatible first.
|
72 |
+
if (array_key_exists('api_key', $request)
|
73 |
+
&& $request['api_key'] != ''
|
74 |
+
) {
|
75 |
+
$store = Mage::helper('nypwidget')->getStoreByApiKey($request['api_key']);
|
76 |
+
$this->_store = $store;
|
77 |
+
} else {
|
78 |
+
// Fallback for when the API key isn't found
|
79 |
+
$this->_store = Mage::app()->getStore();
|
80 |
+
}
|
81 |
+
|
82 |
+
// Is this an existing customer?
|
83 |
+
$customer = Mage::getModel('customer/customer')
|
84 |
+
->setWebsiteId($this->_store->getWebsiteId());
|
85 |
+
$customer->loadByEmail($request['buyer_email']);
|
86 |
+
|
87 |
+
if (!$customer->getId()) {
|
88 |
+
// Create a new customer with this email
|
89 |
+
$customer->reset();
|
90 |
+
$passwordLength = 10;
|
91 |
+
$passwordCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
92 |
+
$password = '';
|
93 |
+
for ($p = 0; $p < $passwordLength; $p++) {
|
94 |
+
$password .= $passwordCharacters[mt_rand(0, strlen($passwordCharacters))];
|
95 |
+
}
|
96 |
+
|
97 |
+
$customer->setEmail($request['buyer_email']);
|
98 |
+
$customer->setFirstname($request['buyer_first_name']);
|
99 |
+
$customer->setLastname($request['buyer_last_name']);
|
100 |
+
$customer->setPassword($password);
|
101 |
+
$customer->setConfirmation(null);
|
102 |
+
$customer->setWebsiteId($this->_store->getWebsiteId());
|
103 |
+
$customer->save();
|
104 |
+
if (Mage::getStoreConfig('pricewaiter/customer_interaction/send_welcome_email')) {
|
105 |
+
$customer->sendNewAccountEmail('registered', '', $this->_store->getId());
|
106 |
+
}
|
107 |
+
$customer->load($customer->getId());
|
108 |
+
}
|
109 |
+
|
110 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
111 |
+
$reservedOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($this->_store->getId());
|
112 |
+
|
113 |
+
$order = Mage::getModel('sales/order')
|
114 |
+
->setIncrementId($reservedOrderId)
|
115 |
+
->setStoreId($this->_store->getId())
|
116 |
+
->setQuoteId(0)
|
117 |
+
->setGlobal_currency_code('USD')
|
118 |
+
->setBase_currency_code('USD')
|
119 |
+
->setStore_currency_code('USD')
|
120 |
+
->setOrder_currency_code('USD');
|
121 |
+
|
122 |
+
// set Customer data
|
123 |
+
$order->setCustomer_email($customer->getEmail())
|
124 |
+
->setCustomerFirstname($customer->getFirstname())
|
125 |
+
->setCustomerLastname($customer->getLastname())
|
126 |
+
->setCustomerGroupId($customer->getGroupId())
|
127 |
+
->setCustomer_is_guest(0)
|
128 |
+
->setCustomer($customer);
|
129 |
+
|
130 |
+
//Get a phone number, or make a dummy one
|
131 |
+
if ($request['buyer_shipping_phone']) {
|
132 |
+
$telephone = $request['buyer_shipping_phone'];
|
133 |
+
} else {
|
134 |
+
$telephone = "000-000-0000";
|
135 |
+
}
|
136 |
+
|
137 |
+
// Find Region ID
|
138 |
+
$regionModel = Mage::getModel('directory/region')->loadByCode($request['buyer_shipping_state'], $request['buyer_shipping_country']);
|
139 |
+
|
140 |
+
// set Billing Address
|
141 |
+
$billing = $customer->getDefaultBillingAddress();
|
142 |
+
$billingAddress = Mage::getModel('sales/order_address')
|
143 |
+
->setStoreId($this->_store->getId())
|
144 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
145 |
+
->setCustomerId($customer->getId())
|
146 |
+
->setPrefix('')
|
147 |
+
->setFirstname($request['buyer_first_name'])
|
148 |
+
->setMiddlename('')
|
149 |
+
->setLastname($request['buyer_last_name'])
|
150 |
+
->setSuffix('')
|
151 |
+
->setCompany('')
|
152 |
+
->setStreet(array($request['buyer_shipping_address'], $request['buyer_shipping_address2']))
|
153 |
+
->setCity($request['buyer_shipping_city'])
|
154 |
+
->setCountry_id($request['buyer_shipping_country'])
|
155 |
+
->setRegion($request['buyer_shipping_state'])
|
156 |
+
->setRegion_id($regionModel->getId())
|
157 |
+
->setPostcode($request['buyer_shipping_zip'])
|
158 |
+
->setTelephone($telephone)
|
159 |
+
->setFax('');
|
160 |
+
$order->setBillingAddress($billingAddress);
|
161 |
+
|
162 |
+
// Try to get the shipping name. If we fail, fall back on the buyer_first/last_name fields
|
163 |
+
preg_match('#^(\w+\.)?\s*([\'\’\w]+)\s+([\'\’\w]+)\s*(\w+\.?)?$#', $request['buyer_shipping_name'], $name);
|
164 |
+
|
165 |
+
if (array_key_exists(2, $name)) {
|
166 |
+
$request['buyer_shipping_first_name'] = $name[2];
|
167 |
+
$request['buyer_shipping_last_name'] = $name[3];
|
168 |
+
} else {
|
169 |
+
$request['buyer_shipping_first_name'] = $request['buyer_first_name'];
|
170 |
+
$request['buyer_shipping_last_name'] = $request['buyer_last_name'];
|
171 |
+
}
|
172 |
+
|
173 |
+
// set Shipping Address
|
174 |
+
$shipping = $customer->getDefaultShippingAddress();
|
175 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
176 |
+
->setStoreId($this->_store->getId())
|
177 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
178 |
+
->setCustomerId($customer->getId())
|
179 |
+
->setPrefix('')
|
180 |
+
->setFirstname($request['buyer_shipping_first_name'])
|
181 |
+
->setMiddlename('')
|
182 |
+
->setLastname($request['buyer_shipping_last_name'])
|
183 |
+
->setSuffix('')
|
184 |
+
->setCompany('')
|
185 |
+
->setStreet(array($request['buyer_shipping_address'], $request['buyer_shipping_address2']))
|
186 |
+
->setCity($request['buyer_shipping_city'])
|
187 |
+
->setCountry_id($request['buyer_shipping_country'])
|
188 |
+
->setRegion($request['buyer_shipping_state'])
|
189 |
+
->setRegion_id($regionModel->getId())
|
190 |
+
->setPostcode($request['buyer_shipping_zip'])
|
191 |
+
->setTelephone($telephone)
|
192 |
+
->setFax('');
|
193 |
+
|
194 |
+
// Apply shipping address to order, add PriceWaiter shipping method
|
195 |
+
$order->setShippingAddress($shippingAddress)
|
196 |
+
->setShipping_method('nypwidget_nypwidget')
|
197 |
+
->setShipping_amount($request['shipping'])
|
198 |
+
->setShippingDescription('PriceWaiter');
|
199 |
+
|
200 |
+
// Add PriceWaiter payment method
|
201 |
+
$orderPayment = Mage::getModel('sales/order_payment')
|
202 |
+
->setStoreId($this->_store->getId())
|
203 |
+
->setCustomerPaymentId(0)
|
204 |
+
->setMethod('nypwidget');
|
205 |
+
$order->setPayment($orderPayment);
|
206 |
+
|
207 |
+
// Find the Product from the request
|
208 |
+
$this->_product = Mage::getModel('catalog/product')->getCollection()
|
209 |
+
->addAttributeToFilter('sku', $request['product_sku'])
|
210 |
+
->addAttributeToSelect('*')
|
211 |
+
->getFirstItem();
|
212 |
+
|
213 |
+
// If we have product options, split them out of the request
|
214 |
+
$requestOptions = array();
|
215 |
+
|
216 |
+
for ($i = $request['product_option_count']; $i > 0; $i--) {
|
217 |
+
$requestOptions[$request['product_option_name' . $i]] = $request['product_option_value' . $i];
|
218 |
+
}
|
219 |
+
|
220 |
+
if ($this->_product->getTypeId() == 'configurable') {
|
221 |
+
// Do configurable product specific stuff
|
222 |
+
$attrs = $this->_product->getTypeInstance(true)->getConfigurableAttributesAsArray($this->_product);
|
223 |
+
|
224 |
+
// Find our product based on attributes
|
225 |
+
foreach ($attrs as $attr) {
|
226 |
+
if (array_key_exists($attr['label'], $requestOptions)) {
|
227 |
+
foreach ($attr['values'] as $value) {
|
228 |
+
if ($value['label'] == $requestOptions[$attr['label']]) {
|
229 |
+
$valueIndex = $value['value_index'];
|
230 |
+
break;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
unset($requestOptions[$attr['label']]);
|
234 |
+
$requestOptions[$attr['attribute_id']] = $valueIndex;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
$parentProduct = $this->_product;
|
239 |
+
$this->_product = $this->_product->getTypeInstance()->getProductByAttributes($requestOptions, $this->_product);
|
240 |
+
$this->_product->load($this->_product->getId());
|
241 |
+
}
|
242 |
+
|
243 |
+
// Build the pricing information of the product
|
244 |
+
$subTotal = 0;
|
245 |
+
$rowTotal = ($request['unit_price'] * $request['quantity']) + $request['tax'];
|
246 |
+
$itemDiscount = ($this->_product->getPrice() - $request['unit_price']);
|
247 |
+
|
248 |
+
$orderItem = Mage::getModel('sales/order_item')
|
249 |
+
->setStoreId($this->_store->getId())
|
250 |
+
->setQuoteItemId(0)
|
251 |
+
->setQuoteParentItemId(NULL)
|
252 |
+
->setProductId($this->_product->getId())
|
253 |
+
->setProductType($this->_product->getTypeId())
|
254 |
+
->setQtyBackordered(NULL)
|
255 |
+
->setTotalQtyOrdered($request['quantity'])
|
256 |
+
->setQtyOrdered($request['quantity'])
|
257 |
+
->setName($this->_product->getName())
|
258 |
+
->setSku($this->_product->getSku())
|
259 |
+
->setPrice($request['unit_price'])
|
260 |
+
->setBasePrice($request['unit_price'])
|
261 |
+
->setOriginalPrice($this->_product->getPrice())
|
262 |
+
// ->setDiscountAmount($itemDiscount)
|
263 |
+
->setTaxAmount($request['tax'])
|
264 |
+
->setRowTotal($rowTotal)
|
265 |
+
->setBaseRowTotal($rowTotal);
|
266 |
+
|
267 |
+
// Do we have a simple product with custom options, a bundle product, or a grouped product?
|
268 |
+
if (($this->_product->getTypeId() == 'simple'
|
269 |
+
|| $this->_product->getTypeId() == 'bundle'
|
270 |
+
|| $this->_product->getTypeId() == 'grouped')
|
271 |
+
&& $request['product_option_count'] > 0
|
272 |
+
) {
|
273 |
+
// Grab the options from the request, build $additionalOptions array
|
274 |
+
$additionalOptions = array();
|
275 |
+
for ($i = $request['product_option_count']; $i > 0; $i--) {
|
276 |
+
$additionalOptions[] = array(
|
277 |
+
'label' => $request['product_option_name' . $i],
|
278 |
+
'value' => $request['product_option_value' . $i]
|
279 |
+
);
|
280 |
+
}
|
281 |
+
|
282 |
+
// Apply the $additionalOptions array to the simple product
|
283 |
+
$orderItem->setProductOptions(array('additional_options' => $additionalOptions));
|
284 |
+
}
|
285 |
+
|
286 |
+
// Build and apply the order totals
|
287 |
+
$subTotal += $rowTotal;
|
288 |
+
$order->addItem($orderItem);
|
289 |
+
|
290 |
+
$order->setSubtotal($subTotal)
|
291 |
+
->setBaseSubtotal($subTotal)
|
292 |
+
->setGrandTotal($subTotal + $request['shipping'])
|
293 |
+
->setBaseGrandTotal($subTotal + $request['shipping']);
|
294 |
+
|
295 |
+
$order->addStatusHistoryComment("This order has been programmatically created by the PriceWaiter Name Your Price Widget.");
|
296 |
+
|
297 |
+
// Ok, done with the order.
|
298 |
+
$transaction->addObject($order);
|
299 |
+
$transaction->addCommitCallback(array($order, 'place'));
|
300 |
+
$transaction->addCommitCallback(array($order, 'save'));
|
301 |
+
$transaction->save();
|
302 |
+
if (Mage::getStoreConfig('pricewaiter/customer_interaction/send_new_order_email')) {
|
303 |
+
$order->sendNewOrderEmail();
|
304 |
+
}
|
305 |
+
|
306 |
+
// Capture the invoice
|
307 |
+
$invoiceId = Mage::getModel('sales/order_invoice_api')
|
308 |
+
->create($order->getIncrementId(), array());
|
309 |
+
$invoice = Mage::getModel('sales/order_invoice')
|
310 |
+
->loadByIncrementId($invoiceId);
|
311 |
+
$invoice->capture()->save();
|
312 |
+
|
313 |
+
// Add this order to the list of received callback orders
|
314 |
+
$pricewaiterOrder->setData(array(
|
315 |
+
'store_id' => $order->getStoreId(),
|
316 |
+
'pricewaiter_id' => $request['pricewaiter_id'],
|
317 |
+
'order_id' => $order->getId()
|
318 |
+
));
|
319 |
+
$pricewaiterOrder->save();
|
320 |
+
|
321 |
+
Mage::log("The Name Your Price Widget has created order #"
|
322 |
+
. $order->getIncrementId() . " with order ID " . $order->getId());
|
323 |
+
$this->_log("The Name Your Price Widget has created order #"
|
324 |
+
. $order->getIncrementId() . " with order ID " . $order->getId());
|
325 |
+
} catch (Exception $e) {
|
326 |
+
$this->_log("PriceWaiter Name Your Price Widget was unable to create order. Check log for details.");
|
327 |
+
$this->_log($e->getMessage());
|
328 |
+
}
|
329 |
+
|
330 |
+
}
|
331 |
+
|
332 |
+
private function _log($message)
|
333 |
+
{
|
334 |
+
if (Mage::getStoreConfig('pricewaiter/configuration/log')) {
|
335 |
+
Mage::log($message, null, "PriceWaiter_Callback.log");
|
336 |
+
}
|
337 |
+
}
|
338 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,20 +16,21 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod
|
19 |
-
|
20 |
-
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod
|
21 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
22 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
23 |
{
|
24 |
+
protected $_code = 'nypwidget';
|
25 |
+
protected $_isFixed = true;
|
26 |
|
27 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
28 |
+
{
|
29 |
+
return;
|
30 |
+
}
|
31 |
|
32 |
+
public function getAllowedMethods()
|
33 |
+
{
|
34 |
+
return;
|
35 |
+
}
|
36 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Category.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,77 +16,78 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Category extends Mage_Core_Model_Abstract
|
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 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Category extends Mage_Core_Model_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/category', 'entity_id');
|
25 |
+
}
|
26 |
|
27 |
+
public function loadByCategory($category, $storeId = null)
|
28 |
+
{
|
29 |
+
if (is_object($category)) {
|
30 |
+
$categoryID = $category->getId();
|
31 |
+
} else {
|
32 |
+
$categoryID = $category;
|
33 |
+
}
|
34 |
|
35 |
+
if (is_null($storeId)) {
|
36 |
+
$storeId = Mage::app()->getStore()->getId();
|
37 |
+
}
|
38 |
|
39 |
+
$collection = Mage::getModel('nypwidget/category')
|
40 |
+
->getCollection()
|
41 |
+
->addFieldToFilter('category_id', $categoryID)
|
42 |
+
->addFieldToFilter('store_id', $storeId);
|
43 |
|
44 |
+
if (count($collection)) {
|
45 |
+
$this->load($collection->getFirstItem()->getEntityId());
|
46 |
+
} else {
|
47 |
+
$this->setData('category_id', $categoryID);
|
48 |
+
$this->setData('store_id', $storeId);
|
49 |
+
$this->save();
|
50 |
+
}
|
51 |
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
|
55 |
+
public function isActive($admin = false)
|
56 |
+
{
|
57 |
+
// If we are in the admin, we want to skip all this, so that we return
|
58 |
+
// the info on this specific category, not parents
|
59 |
+
if (!$admin) {
|
60 |
+
// First, check the "All Store Views" store (0)
|
61 |
+
if ($this->getStoreId() != 0) {
|
62 |
+
$allStoresCategory = Mage::getModel('nypwidget/category')
|
63 |
+
->loadByCategory($this->getCategoryId(), 0);
|
64 |
+
if (!$allStoresCategory->isActive()) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
}
|
68 |
|
69 |
+
// Check the parent category if we already have a category_id and have a parent
|
70 |
+
if (!is_null($this->getData('category_id'))) {
|
71 |
+
$category = Mage::getModel('catalog/category')->load($this->getData('category_id'));
|
72 |
+
if ($category->getParentId() != 0) {
|
73 |
+
$parentCategory = Mage::getModel('nypwidget/category')->loadByCategory($category->getParentId());
|
74 |
+
if (!$parentCategory->isActive()) {
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
|
81 |
+
// If the category isn't yet set in the table, default to true.
|
82 |
+
// Otherwise, check the nypwidget_enabled field.
|
83 |
+
if (is_null($this->getData('category_id')) or $this->getData('nypwidget_enabled') == 1) {
|
84 |
+
return true;
|
85 |
+
}
|
86 |
|
87 |
+
if (is_null($this->getData('nypwidget_enabled'))) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
|
91 |
+
return false;
|
92 |
+
}
|
93 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,6 +16,7 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Display_Phrase
|
19 |
{
|
20 |
public function toOptionArray()
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Display_Phrase
|
21 |
{
|
22 |
public function toOptionArray()
|
app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,6 +16,7 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Display_Size
|
19 |
{
|
20 |
public function toOptionArray()
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Display_Size
|
21 |
{
|
22 |
public function toOptionArray()
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,10 +16,11 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
|
19 |
{
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/category', 'entity_id');
|
25 |
+
}
|
26 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,10 +16,11 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
19 |
{
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/category', 'entity_id');
|
25 |
+
}
|
26 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,10 +16,11 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract
|
19 |
{
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/order', 'entity_id');
|
25 |
+
}
|
26 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,10 +16,11 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
19 |
{
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/order', 'entity_id');
|
25 |
+
}
|
26 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Observer.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,32 +16,33 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Observer
|
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 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Observer
|
21 |
{
|
22 |
+
// Adds the "PriceWaiter" tab to the "Manage Categories" page
|
23 |
+
public function addTab(Varien_Event_Observer $observer)
|
24 |
+
{
|
25 |
+
$tabs = $observer->getEvent()->getTabs();
|
26 |
+
$tabs->addTab('pricewaiter', array(
|
27 |
+
'label' => Mage::helper('catalog')->__('PriceWaiter'),
|
28 |
+
'content' => $tabs->getLayout()->createBlock(
|
29 |
+
'nypwidget/category')->toHtml(),
|
30 |
));
|
31 |
+
return true;
|
32 |
+
}
|
33 |
|
34 |
+
// Saves "PriceWaiter" options from Category page
|
35 |
+
public function saveCategory(Varien_Event_Observer $observer)
|
36 |
+
{
|
37 |
+
$category = $observer->getEvent()->getCategory();
|
38 |
+
$enabled = $observer->getEvent()->getRequest()->getPost();
|
39 |
+
$enabled = $enabled['pricewaiter']['enabled'];
|
40 |
|
41 |
+
// Save the current setting, by category, and store
|
42 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category, $category->getStore()->getId());
|
43 |
+
$nypcategory->setData('nypwidget_enabled', $enabled);
|
44 |
+
$nypcategory->save();
|
45 |
|
46 |
+
return true;
|
47 |
+
}
|
48 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Order.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,28 +16,29 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
|
19 |
{
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
|
42 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
|
21 |
{
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('nypwidget/order', 'entity_id');
|
25 |
+
}
|
26 |
|
27 |
+
public function loadByPriceWaiterId($pricewaiterId)
|
28 |
+
{
|
29 |
+
if (is_null($pricewaiterId)) {
|
30 |
+
return false;
|
31 |
+
}
|
32 |
|
33 |
+
$collection = Mage::getModel('nypwidget/order')
|
34 |
+
->getCollection()
|
35 |
+
->addFieldToFilter('pricewaiter_id', $pricewaiterId);
|
36 |
|
37 |
+
if (count($collection)) {
|
38 |
+
$this->load($collection->getFirstItem()->getEntityId());
|
39 |
+
}
|
40 |
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
|
44 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -20,16 +21,16 @@ class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Metho
|
|
20 |
{
|
21 |
protected $_code = 'nypwidget';
|
22 |
|
23 |
-
protected $_isGateway
|
24 |
-
protected $_canOrder
|
25 |
-
protected $_canAuthorize
|
26 |
-
protected $_canCapture
|
27 |
-
protected $_canCapturePartial
|
28 |
-
protected $_canRefund
|
29 |
-
protected $_canVoid
|
30 |
-
protected $_canUseInternal
|
31 |
-
protected $_canUseCheckout
|
32 |
-
protected $_canUseForMultishipping
|
33 |
|
34 |
public function authorize(Varien_Object $payment, $amount)
|
35 |
{
|
@@ -44,10 +45,10 @@ class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Metho
|
|
44 |
public function void(Varien_Object $payment)
|
45 |
{
|
46 |
return $this;
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
21 |
{
|
22 |
protected $_code = 'nypwidget';
|
23 |
|
24 |
+
protected $_isGateway = false;
|
25 |
+
protected $_canOrder = true;
|
26 |
+
protected $_canAuthorize = false;
|
27 |
+
protected $_canCapture = false;
|
28 |
+
protected $_canCapturePartial = false;
|
29 |
+
protected $_canRefund = false;
|
30 |
+
protected $_canVoid = true;
|
31 |
+
protected $_canUseInternal = true;
|
32 |
+
protected $_canUseCheckout = false;
|
33 |
+
protected $_canUseForMultishipping = false;
|
34 |
|
35 |
public function authorize(Varien_Object $payment, $amount)
|
36 |
{
|
45 |
public function void(Varien_Object $payment)
|
46 |
{
|
47 |
return $this;
|
48 |
+
}
|
49 |
|
50 |
+
public function isAvailable($quote = null)
|
51 |
+
{
|
52 |
+
return false;
|
53 |
+
}
|
54 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -15,6 +16,7 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
|
19 |
{
|
20 |
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
+
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
|
21 |
{
|
22 |
|
app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -15,6 +16,7 @@
|
|
15 |
* limitations under the License.
|
16 |
*
|
17 |
*/
|
|
|
18 |
class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Front_Action
|
19 |
{
|
20 |
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
5 |
*
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
16 |
* limitations under the License.
|
17 |
*
|
18 |
*/
|
19 |
+
|
20 |
class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Front_Action
|
21 |
{
|
22 |
|
app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
app/code/community/PriceWaiter/NYPWidget/etc/config.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
@@ -18,7 +18,7 @@
|
|
18 |
|
19 |
<modules>
|
20 |
<PriceWaiter_NYPWidget>
|
21 |
-
<version>1.
|
22 |
</PriceWaiter_NYPWidget>
|
23 |
</modules>
|
24 |
|
@@ -29,7 +29,7 @@
|
|
29 |
<resourceModel>nypwidget_mysql4</resourceModel>
|
30 |
</nypwidget>
|
31 |
<nypwidget_mysql4>
|
32 |
-
|
33 |
<entities>
|
34 |
<category>
|
35 |
<table>nypwidget_category</table>
|
@@ -79,26 +79,26 @@
|
|
79 |
</nypwidget_read>
|
80 |
</resources>
|
81 |
<events>
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
</events>
|
103 |
</global>
|
104 |
|
@@ -137,15 +137,19 @@
|
|
137 |
<enabled>0</enabled>
|
138 |
<log>1</log>
|
139 |
</configuration>
|
|
|
|
|
|
|
|
|
140 |
<appearance>
|
141 |
<display_size>1</display_size>
|
142 |
<display_color>5F82D4</display_color>
|
143 |
<display_hover_color>739DFF</display_hover_color>
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
<categories>
|
150 |
<disable_by_category>1</disable_by_category>
|
151 |
</categories>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
18 |
|
19 |
<modules>
|
20 |
<PriceWaiter_NYPWidget>
|
21 |
+
<version>1.3.0</version>
|
22 |
</PriceWaiter_NYPWidget>
|
23 |
</modules>
|
24 |
|
29 |
<resourceModel>nypwidget_mysql4</resourceModel>
|
30 |
</nypwidget>
|
31 |
<nypwidget_mysql4>
|
32 |
+
<class>PriceWaiter_NYPWidget_Model_Mysql4</class>
|
33 |
<entities>
|
34 |
<category>
|
35 |
<table>nypwidget_category</table>
|
79 |
</nypwidget_read>
|
80 |
</resources>
|
81 |
<events>
|
82 |
+
<adminhtml_catalog_category_tabs>
|
83 |
+
<observers>
|
84 |
+
<adminhtml_catalog_category_tabs_pricewaiter>
|
85 |
+
<type>model</type>
|
86 |
+
<class>nypwidget/observer</class>
|
87 |
+
<method>addTab</method>
|
88 |
+
<args></args>
|
89 |
+
</adminhtml_catalog_category_tabs_pricewaiter>
|
90 |
+
</observers>
|
91 |
+
</adminhtml_catalog_category_tabs>
|
92 |
+
<catalog_category_prepare_save>
|
93 |
+
<observers>
|
94 |
+
<catalog_category_prepare_save_pricewaiter>
|
95 |
+
<type>model</type>
|
96 |
+
<class>nypwidget/observer</class>
|
97 |
+
<method>saveCategory</method>
|
98 |
+
<args></args>
|
99 |
+
</catalog_category_prepare_save_pricewaiter>
|
100 |
+
</observers>
|
101 |
+
</catalog_category_prepare_save>
|
102 |
</events>
|
103 |
</global>
|
104 |
|
137 |
<enabled>0</enabled>
|
138 |
<log>1</log>
|
139 |
</configuration>
|
140 |
+
<customer_groups>
|
141 |
+
<disable>0</disable>
|
142 |
+
<group_select>0</group_select>
|
143 |
+
</customer_groups>
|
144 |
<appearance>
|
145 |
<display_size>1</display_size>
|
146 |
<display_color>5F82D4</display_color>
|
147 |
<display_hover_color>739DFF</display_hover_color>
|
148 |
+
</appearance>
|
149 |
+
<customer_interaction>
|
150 |
+
<send_welcome_email>0</send_welcome_email>
|
151 |
+
<send_new_order_email>0</send_new_order_email>
|
152 |
+
</customer_interaction>
|
153 |
<categories>
|
154 |
<disable_by_category>1</disable_by_category>
|
155 |
</categories>
|
app/code/community/PriceWaiter/NYPWidget/etc/system.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
@@ -80,6 +80,39 @@
|
|
80 |
</log>
|
81 |
</fields>
|
82 |
</configuration>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
<appearance translate="label">
|
84 |
<label>Appearance</label>
|
85 |
<frontend_type>text</frontend_type>
|
@@ -158,7 +191,7 @@
|
|
158 |
<display_custom_css translate="label comment">
|
159 |
<label>Custom CSS</label>
|
160 |
<comment>
|
161 |
-
|
162 |
the PriceWaiter button. This field is not validated.]]>
|
163 |
</comment>
|
164 |
<frontend_type>text</frontend_type>
|
@@ -181,7 +214,7 @@
|
|
181 |
<send_welcome_email>
|
182 |
<label>Send Welcome Email to New Customers?</label>
|
183 |
<comment>
|
184 |
-
|
185 |
order notification will receive your store's Welcome email in addition to
|
186 |
PriceWaiter's.]]>
|
187 |
</comment>
|
@@ -195,7 +228,7 @@
|
|
195 |
<send_new_order_email>
|
196 |
<label>Send New Order Email to Customers?</label>
|
197 |
<comment>
|
198 |
-
|
199 |
order notification will trigger your store's New Order email in addition to
|
200 |
PriceWaiter's.]]>
|
201 |
</comment>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
80 |
</log>
|
81 |
</fields>
|
82 |
</configuration>
|
83 |
+
<customer_groups translate="label">
|
84 |
+
<label>Customer Groups</label>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>5</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
<expanded>1</expanded>
|
91 |
+
<fields>
|
92 |
+
<disable translate="label comment">
|
93 |
+
<label>Disable the "Name Your Price" widget by customer group?</label>
|
94 |
+
<comment>
|
95 |
+
<![CDATA[Setting this option to "Yes" will disable the widget for customer groups
|
96 |
+
selected below]]>
|
97 |
+
</comment>
|
98 |
+
<frontend_type>select</frontend_type>
|
99 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
100 |
+
<sort_order>0</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
</disable>
|
105 |
+
<group_select translate="label comment">
|
106 |
+
<label>Customer Groups</label>
|
107 |
+
<frontend_type>multiselect</frontend_type>
|
108 |
+
<source_model>customer/resource_group_collection</source_model>
|
109 |
+
<sort_order>10</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
</group_select>
|
114 |
+
</fields>
|
115 |
+
</customer_groups>
|
116 |
<appearance translate="label">
|
117 |
<label>Appearance</label>
|
118 |
<frontend_type>text</frontend_type>
|
191 |
<display_custom_css translate="label comment">
|
192 |
<label>Custom CSS</label>
|
193 |
<comment>
|
194 |
+
<![CDATA[Add custom CSS that will be added to the container that holds
|
195 |
the PriceWaiter button. This field is not validated.]]>
|
196 |
</comment>
|
197 |
<frontend_type>text</frontend_type>
|
214 |
<send_welcome_email>
|
215 |
<label>Send Welcome Email to New Customers?</label>
|
216 |
<comment>
|
217 |
+
<![CDATA[With this enabled, new customers created when Magento receives a new
|
218 |
order notification will receive your store's Welcome email in addition to
|
219 |
PriceWaiter's.]]>
|
220 |
</comment>
|
228 |
<send_new_order_email>
|
229 |
<label>Send New Order Email to Customers?</label>
|
230 |
<comment>
|
231 |
+
<![CDATA[With this enabled, new orders created when Magento receives a new
|
232 |
order notification will trigger your store's New Order email in addition to
|
233 |
PriceWaiter's.]]>
|
234 |
</comment>
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -27,25 +27,25 @@ $installer->removeAttribute('catalog_product', 'nypwidget_enabled');
|
|
27 |
// Add a new attribute to all prodcuts to toggle the Widget on/off
|
28 |
$installer->addAttribute('catalog_product', 'nypwidget_disabled',
|
29 |
array(
|
30 |
-
'group'
|
31 |
-
'label'
|
32 |
-
'type'
|
33 |
-
'input'
|
34 |
-
'default'
|
35 |
-
'class'
|
36 |
-
'backend'
|
37 |
-
'frontend'
|
38 |
-
'source'
|
39 |
-
'global'
|
40 |
-
'visible'
|
41 |
-
'required'
|
42 |
-
'user_defined'
|
43 |
-
'searchable'
|
44 |
-
'filterable'
|
45 |
-
'comparable'
|
46 |
-
'visible_on_front'
|
47 |
'visible_in_advanced_search' => false,
|
48 |
-
'unique'
|
49 |
-
'apply_to'
|
50 |
)
|
51 |
);
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
+
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
27 |
// Add a new attribute to all prodcuts to toggle the Widget on/off
|
28 |
$installer->addAttribute('catalog_product', 'nypwidget_disabled',
|
29 |
array(
|
30 |
+
'group' => 'General',
|
31 |
+
'label' => 'Disable PriceWaiter Widget?',
|
32 |
+
'type' => 'int',
|
33 |
+
'input' => 'boolean',
|
34 |
+
'default' => '0',
|
35 |
+
'class' => '',
|
36 |
+
'backend' => '',
|
37 |
+
'frontend' => '',
|
38 |
+
'source' => '',
|
39 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
40 |
+
'visible' => true,
|
41 |
+
'required' => true,
|
42 |
+
'user_defined' => false,
|
43 |
+
'searchable' => true,
|
44 |
+
'filterable' => true,
|
45 |
+
'comparable' => true,
|
46 |
+
'visible_on_front' => true,
|
47 |
'visible_in_advanced_search' => false,
|
48 |
+
'unique' => false,
|
49 |
+
'apply_to' => $supportTypeIds,
|
50 |
)
|
51 |
);
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.2.4-1.2.5.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
app/design/adminhtml/default/default/layout/pricewaiter.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
-
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
7 |
You may obtain a copy of the License at
|
@@ -17,9 +17,15 @@
|
|
17 |
<layout>
|
18 |
<adminhtml_system_config_edit>
|
19 |
<reference name="head">
|
20 |
-
<action method="addCss"
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
</reference>
|
24 |
<reference name="content">
|
25 |
<block type="nypwidget/adminhtml_widget" name="widget_preview" as="widget_preview" template="pricewaiter/admin_widget.phtml"></block>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
+
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
7 |
You may obtain a copy of the License at
|
17 |
<layout>
|
18 |
<adminhtml_system_config_edit>
|
19 |
<reference name="head">
|
20 |
+
<action method="addCss">
|
21 |
+
<name>pricewaiter.css</name>
|
22 |
+
</action>
|
23 |
+
<action method="addJs">
|
24 |
+
<name>jscolor-pw/jscolor.js</name>
|
25 |
+
</action>
|
26 |
+
<action method="addJs">
|
27 |
+
<name>pricewaiter/product-pages.js</name>
|
28 |
+
</action>
|
29 |
</reference>
|
30 |
<reference name="content">
|
31 |
<block type="nypwidget/adminhtml_widget" name="widget_preview" as="widget_preview" template="pricewaiter/admin_widget.phtml"></block>
|
app/design/adminhtml/default/default/template/pricewaiter/admin_widget.phtml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -18,15 +18,15 @@
|
|
18 |
?>
|
19 |
<?php $helper = $this->_getHelper(); ?>
|
20 |
<script type="text/javascript">
|
21 |
-
//<![CDATA[
|
22 |
-
<?php echo $helper->getPriceWaiterOptions(); ?>
|
23 |
-
<?php echo $helper->getProductOptions(true); ?>
|
24 |
|
25 |
-
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
26 |
|
27 |
-
function adminPW() {
|
28 |
-
|
29 |
-
}
|
30 |
|
31 |
-
//]]>
|
32 |
</script>
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
+
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
18 |
?>
|
19 |
<?php $helper = $this->_getHelper(); ?>
|
20 |
<script type="text/javascript">
|
21 |
+
//<![CDATA[
|
22 |
+
<?php echo $helper->getPriceWaiterOptions(); ?>
|
23 |
+
<?php echo $helper->getProductOptions(true); ?>
|
24 |
|
25 |
+
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
26 |
|
27 |
+
function adminPW() {
|
28 |
+
$('pricewaiter_appearance_preview').up().innerHTML = '<span id="pricewaiter"></span><p class="note"><span> What the "Name Your Price" widget will look like on your product pages. </span></p>';
|
29 |
+
}
|
30 |
|
31 |
+
//]]>
|
32 |
</script>
|
app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
-
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
@@ -16,33 +16,33 @@
|
|
16 |
*
|
17 |
*/
|
18 |
?>
|
19 |
-
<?php
|
20 |
$enabled = $this->getIsEnabled();
|
21 |
?>
|
22 |
<div class="entry-edit">
|
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 |
</div>
|
1 |
+
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
+
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
7 |
* You may obtain a copy of the License at
|
16 |
*
|
17 |
*/
|
18 |
?>
|
19 |
+
<?php
|
20 |
$enabled = $this->getIsEnabled();
|
21 |
?>
|
22 |
<div class="entry-edit">
|
23 |
+
<div class="entry-edit-head">
|
24 |
+
<h4 class="icon-head head-edit-form fieldset-legend">PriceWaiter Widget</h4>
|
25 |
+
</div>
|
26 |
+
<div class="fieldset fieldset-wide" id="group_pricewaiter">
|
27 |
+
<div class="hor-scroll">
|
28 |
+
<table cellspacing="0" class="form-list">
|
29 |
+
<tbody>
|
30 |
|
31 |
+
<tr>
|
32 |
+
<td class="label"><label for="group_pricewaiter_enabled">Enabled</label></td>
|
33 |
+
<td class="value">
|
34 |
+
<select id="group_pricewaiter_enabled" name="pricewaiter[enabled]" class=" select">
|
35 |
+
<option value="1" <?php if ($enabled): ?>selected="selected"<?php endif; ?>>Yes</option>
|
36 |
+
<option value="0" <?php if (!$enabled): ?>selected="selected"<?php endif; ?>>No</option>
|
37 |
+
</select>
|
38 |
+
</td>
|
39 |
+
<td class="scope-label">
|
40 |
+
<span class="nobr">[STORE VIEW]</span>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
|
44 |
+
</tbody>
|
45 |
+
</table>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
</div>
|
app/design/frontend/base/default/layout/pricewaiter.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
@@ -16,11 +16,13 @@
|
|
16 |
-->
|
17 |
<layout>
|
18 |
<catalog_product_view>
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
22 |
<reference name="product.info.addtocart">
|
23 |
-
<block type="nypwidget/widget" name="pricewaiter_widget" template="pricewaiter/widget.phtml" as="pricewaiter.widget"
|
24 |
</reference>
|
25 |
</catalog_product_view>
|
26 |
</layout>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
16 |
-->
|
17 |
<layout>
|
18 |
<catalog_product_view>
|
19 |
+
<reference name="head">
|
20 |
+
<action method="addJs">
|
21 |
+
<name>pricewaiter/product-pages.js</name>
|
22 |
+
</action>
|
23 |
+
</reference>
|
24 |
<reference name="product.info.addtocart">
|
25 |
+
<block type="nypwidget/widget" name="pricewaiter_widget" template="pricewaiter/widget.phtml" as="pricewaiter.widget"/>
|
26 |
</reference>
|
27 |
</catalog_product_view>
|
28 |
</layout>
|
app/design/frontend/base/default/template/pricewaiter/widget.phtml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* Copyright 2013 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
@@ -17,21 +17,22 @@
|
|
17 |
*/
|
18 |
?>
|
19 |
<?php $_product = Mage::registry('current_product'); ?>
|
20 |
-
<?php if($_product->isSaleable()): ?>
|
21 |
-
<?php
|
22 |
-
$customCss = Mage::getStoreConfig('pricewaiter/appearance/display_custom_css');
|
23 |
-
$helper = $this->_getHelper();
|
24 |
-
if ($helper->isEnabled()):
|
25 |
-
?>
|
26 |
-
<script type="text/javascript">
|
27 |
-
//<![CDATA[
|
28 |
-
<?php echo $helper->getPriceWaiterOptions(); ?>
|
29 |
-
<?php echo $helper->getProductOptions(); ?>
|
30 |
-
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
31 |
-
//]]>
|
32 |
-
</script>
|
33 |
-
<div class="name-your-price-widget"
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
<?php endif; ?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
4 |
*
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
* you may not use this file except in compliance with the License.
|
17 |
*/
|
18 |
?>
|
19 |
<?php $_product = Mage::registry('current_product'); ?>
|
20 |
+
<?php if ($_product->isSaleable()): ?>
|
21 |
+
<?php
|
22 |
+
$customCss = Mage::getStoreConfig('pricewaiter/appearance/display_custom_css');
|
23 |
+
$helper = $this->_getHelper();
|
24 |
+
if ($helper->isEnabled()):
|
25 |
+
?>
|
26 |
+
<script type="text/javascript">
|
27 |
+
//<![CDATA[
|
28 |
+
<?php echo $helper->getPriceWaiterOptions(); ?>
|
29 |
+
<?php echo $helper->getProductOptions(); ?>
|
30 |
+
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
31 |
+
//]]>
|
32 |
+
</script>
|
33 |
+
<div class="name-your-price-widget"
|
34 |
+
style='display: block; clear: both; padding-top: 10px; <?php echo $customCss; ?>'>
|
35 |
+
<span id="pricewaiter"></span>
|
36 |
+
</div>
|
37 |
+
<?php endif; ?>
|
38 |
<?php endif; ?>
|
app/etc/modules/PriceWaiter_NYPWidget.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
-
Copyright 2013 Price Waiter, LLC
|
4 |
-
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
7 |
You may obtain a copy of the License at
|
@@ -19,6 +19,6 @@
|
|
19 |
<PriceWaiter_NYPWidget>
|
20 |
<active>true</active>
|
21 |
<codePool>community</codePool>
|
22 |
-
|
23 |
</modules>
|
24 |
</config>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<!--
|
3 |
+
Copyright 2013-2014 Price Waiter, LLC
|
4 |
+
|
5 |
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
you may not use this file except in compliance with the License.
|
7 |
You may obtain a copy of the License at
|
19 |
<PriceWaiter_NYPWidget>
|
20 |
<active>true</active>
|
21 |
<codePool>community</codePool>
|
22 |
+
</PriceWaiter_NYPWidget>
|
23 |
</modules>
|
24 |
</config>
|
js/pricewaiter/product-pages.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*
|
2 |
-
* Copyright 2013 Price Waiter, LLC
|
3 |
*
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
* you may not use this file except in compliance with the License.
|
@@ -14,285 +14,285 @@
|
|
14 |
* limitations under the License.
|
15 |
*
|
16 |
*/
|
17 |
-
$(document).observe('dom:loaded', function() {
|
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 |
-
|
253 |
-
|
254 |
|
255 |
-
|
256 |
-
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
});
|
1 |
/*
|
2 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
3 |
*
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
* you may not use this file except in compliance with the License.
|
14 |
* limitations under the License.
|
15 |
*
|
16 |
*/
|
17 |
+
$(document).observe('dom:loaded', function () {
|
18 |
+
if (typeof adminPW == 'function') {
|
19 |
+
adminPW();
|
20 |
+
}
|
21 |
+
if (typeof PriceWaiterOptions == 'object') {
|
22 |
+
PriceWaiterOptions.onload =
|
23 |
+
function (PriceWaiter) {
|
24 |
+
PriceWaiter.setRegularPrice(PriceWaiterRegularPrice);
|
25 |
|
26 |
+
// define indexof, needed for older versions of IE
|
27 |
+
if (!Array.prototype.indexof) {
|
28 |
+
Array.prototype.indexof = function (needle) {
|
29 |
+
for (var i = 0; i < this.length; i++) {
|
30 |
+
if (this[i] === needle) {
|
31 |
+
return i;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return -1;
|
35 |
+
};
|
36 |
+
}
|
37 |
|
38 |
+
// define getElementsByRegex to find required bundle options
|
39 |
+
document['getElementsByRegex'] = function (pattern) {
|
40 |
+
var arrElements = []; // to accumulate matching elements
|
41 |
+
var re = new RegExp(pattern); // the regex to match with
|
42 |
|
43 |
+
function findRecursively(aNode) { // recursive function to traverse dom
|
44 |
+
if (!aNode)
|
45 |
+
return;
|
46 |
+
if (aNode.id !== undefined && aNode.id.search(re) != -1)
|
47 |
+
arrElements.push(aNode); // found one!
|
48 |
+
for (var idx in aNode.childNodes) // search children...
|
49 |
+
findRecursively(aNode.childNodes[idx]);
|
50 |
+
}
|
51 |
|
52 |
+
findRecursively(document); // initiate recursive matching
|
53 |
+
return arrElements; // return matching elements
|
54 |
+
};
|
55 |
|
56 |
+
// Bind to Qty: input
|
57 |
+
if ($('qty') !== null) {
|
58 |
+
$('qty').observe('change', function () {
|
59 |
+
PriceWaiter.setQuantity($('qty').value);
|
60 |
+
});
|
61 |
+
}
|
62 |
|
63 |
+
switch (PriceWaiterProductType) {
|
64 |
+
case 'simple':
|
65 |
+
handleSimples();
|
66 |
+
break;
|
67 |
+
case 'configurable':
|
68 |
+
handleConfigurables();
|
69 |
+
break;
|
70 |
+
case 'bundle':
|
71 |
+
handleBundles();
|
72 |
+
break;
|
73 |
+
case 'grouped':
|
74 |
+
handleGrouped();
|
75 |
+
break;
|
76 |
+
}
|
77 |
|
78 |
+
function simplesSelect(select, name) {
|
79 |
+
select.observe('change', function () {
|
80 |
+
PriceWaiter.setProductOption(name, select.options[select.selectedIndex].text);
|
81 |
+
});
|
82 |
+
}
|
83 |
|
84 |
+
function simplesInput(select, name) {
|
85 |
+
if (select.type == "text" || select.tagName == 'TEXTAREA') {
|
86 |
+
select.observe('change', function () {
|
87 |
+
PriceWaiter.setProductOption(name, select.value);
|
88 |
+
});
|
89 |
+
} else {
|
90 |
+
select.observe('change', function () {
|
91 |
+
var optionValue = select.next('span').select('label')[0].innerHTML;
|
92 |
+
optionValue = optionValue.replace(/\s*<span.*\/span>/, '');
|
93 |
+
PriceWaiter.setProductOption(name, optionValue);
|
94 |
+
});
|
95 |
+
}
|
96 |
+
}
|
97 |
|
98 |
|
99 |
+
function handleSimples() {
|
100 |
+
// if there are no custom options, we don't have anything to do
|
101 |
+
if (typeof(opConfig) == 'undefined') {
|
102 |
+
return;
|
103 |
+
}
|
104 |
|
105 |
+
// If this product has an upload file option, we can't use the NYP widget
|
106 |
+
var productForm = $('product_addtocart_form');
|
107 |
+
if (productForm.getInputs('file').length !== 0) {
|
108 |
+
console.log("The PriceWaiter Name Your Price Widget does not support upload file options.");
|
109 |
+
$$('div.name-your-price-widget').each(function (pww) {
|
110 |
+
pww.setStyle({display: 'none'});
|
111 |
+
});
|
112 |
+
}
|
113 |
|
114 |
+
// Grab the updated price before opening the PriceWaiter window
|
115 |
+
PriceWaiter.originalOpen = PriceWaiter.open;
|
116 |
+
PriceWaiter.open = function () {
|
117 |
+
var productPrice = 0;
|
118 |
+
var priceElement = document.getElementsByRegex('^product-price-');
|
119 |
+
var innerSpan = priceElement[0].select('span');
|
120 |
+
if (typeof(innerSpan[0]) == 'undefined') {
|
121 |
+
productPrice = priceElement[0].innerHTML;
|
122 |
+
} else {
|
123 |
+
productPrice = innerSpan[0].innerHTML;
|
124 |
+
}
|
125 |
+
PriceWaiter.setPrice(productPrice);
|
126 |
+
PriceWaiter.originalOpen();
|
127 |
+
};
|
128 |
|
129 |
+
// Find the available options, and bind to them
|
130 |
+
var productCustomOptions = $$('.product-custom-option');
|
131 |
+
for (var current in productCustomOptions) {
|
132 |
+
if (!isNaN(parseInt(current, 10))) {
|
133 |
+
// Find the option label
|
134 |
+
var optionLabel = productCustomOptions[current].up('dd').previous('dt').select('label')[0];
|
135 |
+
var optionName = optionLabel.innerHTML.replace(/^<em.*\/em>/, '');
|
136 |
+
// Check if this is a required option
|
137 |
+
if (optionLabel.hasClassName('required')) {
|
138 |
+
PriceWaiter.setProductOptionRequired(optionName);
|
139 |
+
}
|
140 |
+
// we have to handle different inputs a bit differently.
|
141 |
+
switch (productCustomOptions[current].tagName) {
|
142 |
+
case 'SELECT':
|
143 |
+
simplesSelect(productCustomOptions[current], optionName);
|
144 |
+
break;
|
145 |
+
case 'INPUT':
|
146 |
+
case 'TEXTAREA':
|
147 |
+
simplesInput(productCustomOptions[current], optionName);
|
148 |
+
break;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
|
154 |
+
function handleConfigurables() {
|
155 |
+
// Bind to each configurable options 'change' event
|
156 |
+
spConfig.settings.each(function (setting) {
|
157 |
+
var attributeId = $(setting).id;
|
158 |
+
attributeId = attributeId.replace(/attribute/, '');
|
159 |
+
var optionName = spConfig.config.attributes[attributeId].label;
|
160 |
+
// If this option is required, tell the PriceWaiter widget about the requirement
|
161 |
+
if ($(setting).hasClassName('required-entry') && (typeof PriceWaiter.setProductOptionRequired == 'function')) {
|
162 |
+
PriceWaiter.setProductOptionRequired(optionName, true);
|
163 |
+
}
|
164 |
+
Event.observe(setting, 'change', function (event) {
|
165 |
+
// Update PriceWaiter's price and options when changes are made
|
166 |
+
PriceWaiter.setPrice(Number(spConfig.config.basePrice) + Number(spConfig.reloadPrice()));
|
167 |
+
var optionValue = setting.value !== "" ? setting.options[setting.selectedIndex].innerHTML : undefined;
|
168 |
+
// if the option value is undefined, clear the option. Otherwise, set the newly selected option.
|
169 |
+
if (optionValue === undefined) {
|
170 |
+
PriceWaiter.clearProductOption(optionName);
|
171 |
+
} else {
|
172 |
+
PriceWaiter.setProductOption(optionName, optionValue);
|
173 |
+
}
|
174 |
+
});
|
175 |
+
});
|
176 |
+
}
|
177 |
|
178 |
+
function handleBundles() {
|
179 |
+
// Find options that are marked as required
|
180 |
+
var requiredOptions = [];
|
181 |
+
var bundleElements = document.getElementsByRegex('^bundle-option-');
|
182 |
+
var rePattern = /\[(\d*)\]/;
|
183 |
+
for (var bundleOption in bundleElements) {
|
184 |
+
if (!isNaN(parseInt(bundleOption, 10))) {
|
185 |
+
var obj = bundleElements[bundleOption];
|
186 |
+
if (obj.hasClassName('required-entry') || obj.hasClassName('validate-one-required-by-name')) {
|
187 |
+
var matched = rePattern.exec(obj.name);
|
188 |
+
requiredOptions.push(parseInt(matched[1], 10));
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
requiredOptions = requiredOptions.uniq();
|
193 |
|
194 |
+
// Add required Options to PriceWaiter
|
195 |
+
for (var key in bundle.config.options) {
|
196 |
+
if (requiredOptions.indexOf(parseInt(key, 10)) > -1) {
|
197 |
+
var opt = bundle.config.options[key];
|
198 |
+
PriceWaiter.setProductOptionRequired(opt.title, true);
|
199 |
+
}
|
200 |
+
}
|
201 |
|
202 |
+
// Bind to event fired when price is changed on bundle
|
203 |
+
document.observe("bundle:reload-price", function (event) {
|
204 |
+
PriceWaiter.setPrice(event.memo.priceInclTax);
|
205 |
+
var bSelected = event.memo.bundle.config.selected;
|
206 |
+
var bOptions = event.memo.bundle.config.options;
|
207 |
+
for (var current in bSelected) {
|
208 |
+
// Find which value is selected
|
209 |
+
var currentSelected = bSelected[current];
|
210 |
+
if (currentSelected.length === 0) {
|
211 |
+
// If none, unset the Product option
|
212 |
+
PriceWaiter.clearProductOption(bOptions[current].title);
|
213 |
+
} else {
|
214 |
+
// Otherwise, find the quantity of the selection
|
215 |
+
var qty = bOptions[current].selections[currentSelected].qty;
|
216 |
+
// Now find the value of the selected option, and set priceInclTax
|
217 |
+
var selectedValue = bOptions[current].selections[currentSelected].name;
|
218 |
+
if (qty > 1) {
|
219 |
+
selectedValue += " - Quantity: " + qty;
|
220 |
+
}
|
221 |
+
PriceWaiter.setProductOption(bOptions[current].title, selectedValue);
|
222 |
+
}
|
223 |
+
}
|
224 |
+
});
|
225 |
|
226 |
+
// Reload the bundle's price, to pull the initial options into PriceWaiter
|
227 |
+
if (typeof(bundle) != 'undefined') {
|
228 |
+
bundle.reloadPrice();
|
229 |
+
}
|
230 |
+
}
|
231 |
|
232 |
+
function handleGrouped() {
|
233 |
+
// Get the Grouped product table rows
|
234 |
+
var productTable = $$('table.grouped-items-table')[0];
|
235 |
+
var productRows = productTable.select('tbody')[0];
|
236 |
+
productRows = productRows.childElements();
|
237 |
+
// Prevent users from attempting to name a price on grouped products without
|
238 |
+
// setting any quantities
|
239 |
+
if (productRows.length > 0) {
|
240 |
+
PriceWaiter.setProductOptionRequired('Quantity of Products', true);
|
241 |
+
}
|
242 |
|
243 |
+
for (var row in productRows) {
|
244 |
+
if (!isNaN(parseInt(row, 10))) {
|
245 |
+
// Bind to the Quantity change
|
246 |
+
productRows[row].select('input.qty')[0].observe('change', function (event) {
|
247 |
+
var qty = this.value;
|
248 |
+
// Find the name and price based on the input's product ID
|
249 |
+
// The product ID is found in the input's name inside the square brackets
|
250 |
+
var pattern = /\[(.*)\]/;
|
251 |
+
var inputName = this.name;
|
252 |
+
var productID = pattern.exec(inputName);
|
253 |
+
productID = productID[1];
|
254 |
|
255 |
+
var productName = window.PriceWaiterGroupedProductInfo[productID][0];
|
256 |
+
var productPrice = window.PriceWaiterGroupedProductInfo[productID][1];
|
257 |
|
258 |
+
// The user changed the quantity field. We need to find the previous quantity and price
|
259 |
+
var previousQuantity = PriceWaiter.getProductOptions()[productName + " (" + productPrice + ")"];
|
260 |
+
var amountToRemove = Number(previousQuantity * productPrice);
|
261 |
+
if (qty > 0) {
|
262 |
+
// Entered a quantity, set product name as option name, add quantity as value
|
263 |
+
PriceWaiter.setProductOption(productName + " (" + productPrice + ")", qty);
|
264 |
+
// Add the price to the product's total
|
265 |
+
PriceWaiter.setPrice(Number(PriceWaiter.getPrice()) + Number(productPrice * qty));
|
266 |
+
} else {
|
267 |
+
PriceWaiter.clearProductOption(productName + " (" + productPrice + ")");
|
268 |
+
}
|
269 |
+
// If they previously had a quantity for this option, remove it from the total
|
270 |
+
if (previousQuantity > 0) {
|
271 |
+
PriceWaiter.setPrice(Number(PriceWaiter.getPrice() - amountToRemove));
|
272 |
+
}
|
273 |
+
// Test if any Product Options are set. If they are, we can disable
|
274 |
+
// our required option. Otherwise, ensure it is in place.
|
275 |
+
if (Object.keys(PriceWaiter.getProductOptions()).length > 0) {
|
276 |
+
PriceWaiter.clearRequiredProductOptions();
|
277 |
+
} else {
|
278 |
+
PriceWaiter.setProductOptionRequired('Quantity of Products', true);
|
279 |
+
}
|
280 |
+
});
|
281 |
+
}
|
282 |
+
}
|
283 |
+
}
|
284 |
+
};
|
285 |
+
}
|
286 |
|
287 |
+
if (window.PriceWaiterWidgetUrl) {
|
288 |
+
(function () {
|
289 |
+
var pw = document.createElement('script');
|
290 |
+
pw.type = 'text/javascript';
|
291 |
+
pw.src = window.PriceWaiterWidgetUrl;
|
292 |
+
pw.async = true;
|
293 |
|
294 |
+
var s = document.getElementsByTagName('script')[0];
|
295 |
+
s.parentNode.insertBefore(pw, s);
|
296 |
+
})();
|
297 |
+
}
|
298 |
});
|
package.xml
CHANGED
@@ -1,21 +1,158 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>nypwidget</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>PriceWaiter® let's buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
|
10 |
-
<description>Sell more, immediately, with the PriceWaiter® widget. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.
|
11 |
-
|
12 |
-
<
|
13 |
-
|
14 |
-
</
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<compatible/>
|
20 |
-
<dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>nypwidget</name>
|
4 |
+
<version>1.3.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>PriceWaiter® let's buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
|
10 |
+
<description>Sell more, immediately, with the PriceWaiter® widget. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.

 PriceWaiter® lets customers make offers on products you sell-- offers you can accept, reject or counter. The widget embeds a simple Name Your Price button on any product page or category that you choose. Simply install the extension and you'll have full control over PriceWaiter® in your Magento admin control panel.</description>
|
11 |
+
<notes>Features:
- This release adds the ability to disable the PriceWaiter widget by Customer Group.</notes>
|
12 |
+
<authors>
|
13 |
+
<author>
|
14 |
+
<name>PriceWaiter</name>
|
15 |
+
<user>pricewaiter</user>
|
16 |
+
<email>bobby.b@pricewaiter.com</email>
|
17 |
+
</author>
|
18 |
+
</authors>
|
19 |
+
<date>2014-02-17</date>
|
20 |
+
<time>21:05:35</time>
|
21 |
+
<contents>
|
22 |
+
<target name="magecommunity">
|
23 |
+
<dir name="PriceWaiter">
|
24 |
+
<dir name="NYPWidget">
|
25 |
+
<dir name="Block">
|
26 |
+
<dir name="Adminhtml">
|
27 |
+
<file name="Widget.php" hash="cffdba25dabdb8f9b6a2eac21c0e82e0"/>
|
28 |
+
</dir>
|
29 |
+
<file name="Category.php" hash="ba5bcfb87399356266eb2874bf691d6e"/>
|
30 |
+
<file name="Widget.php" hash="25489ee6ae666d91db98b70dd6adbf40"/>
|
31 |
+
</dir>
|
32 |
+
<dir name="Helper">
|
33 |
+
<file name="Data.php" hash="c1a354ddc07fa2cd3c1adee7ac843b7e"/>
|
34 |
+
</dir>
|
35 |
+
<dir name="Model">
|
36 |
+
<file name="Callback.php" hash="1e9f3840e9e3ee1c07e5f9ae9e8fc9c3"/>
|
37 |
+
<dir name="Carrier">
|
38 |
+
<file name="ShippingMethod.php" hash="1df7b75009a6e6e8e41b554fecb813db"/>
|
39 |
+
</dir>
|
40 |
+
<file name="Category.php" hash="55588e458cacb778b92fdacd8edeb22a"/>
|
41 |
+
<dir name="Display">
|
42 |
+
<file name="Phrase.php" hash="ad605b93302ec648c5a7d3e3401f47b5"/>
|
43 |
+
<file name="Size.php" hash="42c2917e730811b78fd12e7591cb9159"/>
|
44 |
+
</dir>
|
45 |
+
<dir name="Mysql4">
|
46 |
+
<dir name="Category">
|
47 |
+
<file name="Collection.php" hash="adbbb19ccafb1498bb0d4c5d20abddd1"/>
|
48 |
+
</dir>
|
49 |
+
<file name="Category.php" hash="ba6b693541711d91edc5b7edae799a97"/>
|
50 |
+
<dir name="Order">
|
51 |
+
<file name="Collection.php" hash="de7e92559722c9735b32a6d30862087e"/>
|
52 |
+
</dir>
|
53 |
+
<file name="Order.php" hash="237302190fa65833b5ff187dd0bbe71a"/>
|
54 |
+
</dir>
|
55 |
+
<file name="Observer.php" hash="a5b643d09e366068028dc1df1abee154"/>
|
56 |
+
<file name="Order.php" hash="c44f2d228a38e991843cee197abd397c"/>
|
57 |
+
<file name="PaymentMethod.php" hash="0106a5c193079d4cf07005fc9d22dd29"/>
|
58 |
+
<dir name="Resource">
|
59 |
+
<dir name="Eav">
|
60 |
+
<dir name="Mysql4">
|
61 |
+
<file name="Setup.php" hash="da87eaa37fc5a09a5d5c38f9bbecabb1"/>
|
62 |
+
</dir>
|
63 |
+
</dir>
|
64 |
+
</dir>
|
65 |
+
</dir>
|
66 |
+
<dir name="controllers">
|
67 |
+
<file name="CallbackController.php" hash="8b95003b06ebc0e1a05430655f2caacd"/>
|
68 |
+
</dir>
|
69 |
+
<dir name="etc">
|
70 |
+
<file name="adminhtml.xml" hash="022f1761ba091c7e1f3e4901d40d5ce0"/>
|
71 |
+
<file name="config.xml" hash="19448d614d5e5c1686b8095bc4fd7e5f"/>
|
72 |
+
<file name="system.xml" hash="8b65aaf26f9bb75eee863e169b25a7ae"/>
|
73 |
+
</dir>
|
74 |
+
<dir name="sql">
|
75 |
+
<dir name="nypwidget_setup">
|
76 |
+
<file name="mysql4-install-1.0.0.php" hash="b30a0b38090a9c7aafb1a419b21755fe"/>
|
77 |
+
<file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="8d4bd167694c277a0e8ab8034d87cb1b"/>
|
78 |
+
<file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="2a8de13744724f647e23e612ecf1d196"/>
|
79 |
+
<file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="4b0ef14d3e455afea1d966f8f1641d6b"/>
|
80 |
+
</dir>
|
81 |
+
</dir>
|
82 |
+
</dir>
|
83 |
+
</dir>
|
84 |
+
</target>
|
85 |
+
<target name="magedesign">
|
86 |
+
<dir name="adminhtml">
|
87 |
+
<dir name="default">
|
88 |
+
<dir name="default">
|
89 |
+
<dir name="layout">
|
90 |
+
<file name="pricewaiter.xml" hash="cc51462b56118a611be1a329b308d528"/>
|
91 |
+
</dir>
|
92 |
+
<dir name="template">
|
93 |
+
<dir name="pricewaiter">
|
94 |
+
<file name="admin_widget.phtml" hash="daae86cfa34fbe5e786715c0c579e398"/>
|
95 |
+
<file name="categorytab.phtml" hash="43f8af9feca6775e4a1e8a149a86268e"/>
|
96 |
+
</dir>
|
97 |
+
</dir>
|
98 |
+
</dir>
|
99 |
+
</dir>
|
100 |
+
</dir>
|
101 |
+
<dir name="frontend">
|
102 |
+
<dir name="base">
|
103 |
+
<dir name="default">
|
104 |
+
<dir name="layout">
|
105 |
+
<file name="pricewaiter.xml" hash="0da284d426574c7ae1f154b096f8b413"/>
|
106 |
+
</dir>
|
107 |
+
<dir name="template">
|
108 |
+
<dir name="pricewaiter">
|
109 |
+
<file name="widget.phtml" hash="d4e9f431922f843d5911a8b9ec2b814e"/>
|
110 |
+
</dir>
|
111 |
+
</dir>
|
112 |
+
</dir>
|
113 |
+
</dir>
|
114 |
+
</dir>
|
115 |
+
</target>
|
116 |
+
<target name="mageetc">
|
117 |
+
<dir name="modules">
|
118 |
+
<file name="PriceWaiter_NYPWidget.xml" hash="d3b86fa976b99e64df65f9e98d689257"/>
|
119 |
+
</dir>
|
120 |
+
</target>
|
121 |
+
<target name="mage">
|
122 |
+
<dir name="js">
|
123 |
+
<dir name="jscolor-pw">
|
124 |
+
<file name="arrow.gif" hash="5034704a76cd55c1cbcbc58ea6bf523f"/>
|
125 |
+
<file name="cross.gif" hash="ba9a274b9323753cd95bc3b1eb2f4e5f"/>
|
126 |
+
<file name="hs.png" hash="fefa1a03d92ebad25c88dca94a0b63db"/>
|
127 |
+
<file name="hv.png" hash="990d71cada17da100653636cf8490884"/>
|
128 |
+
<file name="jscolor.js" hash="668050b57cb3ad59d0a56a16fddf1a91"/>
|
129 |
+
</dir>
|
130 |
+
<dir name="pricewaiter">
|
131 |
+
<file name="product-pages.js" hash="b2b6833f7307963d3da6bb4e785f2540"/>
|
132 |
+
</dir>
|
133 |
+
</dir>
|
134 |
+
</target>
|
135 |
+
<target name="mageskin">
|
136 |
+
<dir name="adminhtml">
|
137 |
+
<dir name="default">
|
138 |
+
<dir name="default">
|
139 |
+
<dir name="images">
|
140 |
+
<file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/>
|
141 |
+
<file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/>
|
142 |
+
</dir>
|
143 |
+
<file name="pricewaiter.css" hash="6a58cdaa35d8f61cbb305a6a1a206816"/>
|
144 |
+
</dir>
|
145 |
+
</dir>
|
146 |
+
</dir>
|
147 |
+
</target>
|
148 |
+
</contents>
|
149 |
<compatible/>
|
150 |
+
<dependencies>
|
151 |
+
<required>
|
152 |
+
<php>
|
153 |
+
<min>5.2.0</min>
|
154 |
+
<max>6.0.0</max>
|
155 |
+
</php>
|
156 |
+
</required>
|
157 |
+
</dependencies>
|
158 |
</package>
|
skin/adminhtml/default/default/pricewaiter.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/*
|
2 |
-
* Copyright 2013 Price Waiter, LLC
|
3 |
-
*
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
* you may not use this file except in compliance with the License.
|
6 |
* You may obtain a copy of the License at
|
@@ -15,35 +15,35 @@
|
|
15 |
*
|
16 |
*/
|
17 |
h3.pricewaiter-header {
|
18 |
-
background:url(images/pricewaiter_logo.png) no-repeat 0 0;
|
19 |
-
height:0px;
|
20 |
-
overflow:hidden;
|
21 |
-
padding:50px 0 0 0;
|
22 |
margin: 0px;
|
23 |
-
width:145px;
|
24 |
}
|
25 |
|
26 |
ul.tabs a.pricewaiter-tab,
|
27 |
ul.tabs a.pricewaiter-tab:hover {
|
28 |
-
background:url(images/tabs_span_bg.gif) repeat-x 0 100%;
|
29 |
-
|
30 |
-
|
31 |
}
|
32 |
|
33 |
ul.tabs a.pricewaiter-tab:hover {
|
34 |
-
background-color
|
35 |
}
|
36 |
|
37 |
ul.tabs a.pricewaiter-tab.active,
|
38 |
ul.tabs a.pricewaiter-tab.active:hover {
|
39 |
-
background-color
|
40 |
}
|
41 |
|
42 |
ul.tabs a.pricewaiter-tab span,
|
43 |
ul.tabs a.pricewaiter-tab:hover span {
|
44 |
-
background:url(images/pricewaiter_tab.png) no-repeat 0 0;
|
45 |
-
height:0;
|
46 |
-
overflow:hidden;
|
47 |
-
padding:14px 0 0;
|
48 |
-
width:300x;
|
49 |
}
|
1 |
/*
|
2 |
+
* Copyright 2013-2014 Price Waiter, LLC
|
3 |
+
*
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
* you may not use this file except in compliance with the License.
|
6 |
* You may obtain a copy of the License at
|
15 |
*
|
16 |
*/
|
17 |
h3.pricewaiter-header {
|
18 |
+
background: url(images/pricewaiter_logo.png) no-repeat 0 0;
|
19 |
+
height: 0px;
|
20 |
+
overflow: hidden;
|
21 |
+
padding: 50px 0 0 0;
|
22 |
margin: 0px;
|
23 |
+
width: 145px;
|
24 |
}
|
25 |
|
26 |
ul.tabs a.pricewaiter-tab,
|
27 |
ul.tabs a.pricewaiter-tab:hover {
|
28 |
+
background: url(images/tabs_span_bg.gif) repeat-x 0 100%;
|
29 |
+
border-bottom: none;
|
30 |
+
padding: 0.5em 0.5em 0.28em 1.5em;
|
31 |
}
|
32 |
|
33 |
ul.tabs a.pricewaiter-tab:hover {
|
34 |
+
background-color: #d8e6e6;
|
35 |
}
|
36 |
|
37 |
ul.tabs a.pricewaiter-tab.active,
|
38 |
ul.tabs a.pricewaiter-tab.active:hover {
|
39 |
+
background-color: #fff;
|
40 |
}
|
41 |
|
42 |
ul.tabs a.pricewaiter-tab span,
|
43 |
ul.tabs a.pricewaiter-tab:hover span {
|
44 |
+
background: url(images/pricewaiter_tab.png) no-repeat 0 0;
|
45 |
+
height: 0;
|
46 |
+
overflow: hidden;
|
47 |
+
padding: 14px 0 0;
|
48 |
+
width: 300x;
|
49 |
}
|