Version Notes
Bug Fix:
- Resolved issue that caused Billing Address to be duplicate of Shipping Address.
Download this release
Release Info
| Developer | PriceWaiter |
| Extension | nypwidget |
| Version | 2.1.2 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.1 to 2.1.2
- app/code/community/PriceWaiter/NYPWidget/Helper/Data.php +72 -8
- app/code/community/PriceWaiter/NYPWidget/Model/Callback.php +24 -22
- app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php +2 -0
- app/code/community/PriceWaiter/NYPWidget/controllers/ProductinfoController.php +1 -0
- app/code/community/PriceWaiter/pwconfig.local.php +7 -0
- app/design/frontend/base/default/layout/pricewaiter.xml +2 -1
- app/design/frontend/base/default/template/pricewaiter/widget.phtml +5 -1
- js/pricewaiter/product-pages.js +1 -255
- package.xml +5 -5
app/code/community/PriceWaiter/NYPWidget/Helper/Data.php
CHANGED
|
@@ -17,6 +17,10 @@
|
|
| 17 |
*
|
| 18 |
*/
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
| 21 |
{
|
| 22 |
private $_product = false;
|
|
@@ -24,6 +28,25 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 24 |
private $_buttonEnabled = null;
|
| 25 |
private $_conversionToolsEnabled = null;
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
public function isTesting()
|
| 28 |
{
|
| 29 |
return $this->_testing;
|
|
@@ -151,28 +174,24 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 151 |
public function getButtonSettingsUrl()
|
| 152 |
{
|
| 153 |
$apiKey = Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
| 154 |
-
$baseUrl = 'https://manage.pricewaiter.com';
|
| 155 |
-
if ($this->_testing) {
|
| 156 |
-
$baseUrl = 'https://manage-staging.pricewaiter.com';
|
| 157 |
-
}
|
| 158 |
|
| 159 |
-
return sprintf("%s/stores/%s/button", $
|
| 160 |
}
|
| 161 |
|
| 162 |
public function getWidgetUrl()
|
| 163 |
{
|
| 164 |
if ($this->isEnabledForStore()) {
|
| 165 |
-
return
|
| 166 |
. Mage::getStoreConfig('pricewaiter/configuration/api_key')
|
| 167 |
. ".js";
|
| 168 |
}
|
| 169 |
|
| 170 |
-
return
|
| 171 |
}
|
| 172 |
|
| 173 |
public function getApiUrl()
|
| 174 |
{
|
| 175 |
-
return
|
| 176 |
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
| 177 |
}
|
| 178 |
|
|
@@ -363,4 +382,49 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 363 |
|
| 364 |
return min($costs);
|
| 365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
}
|
| 17 |
*
|
| 18 |
*/
|
| 19 |
|
| 20 |
+
if (is_file(dirname(__FILE__).'/../../pwconfig.local.php')) {
|
| 21 |
+
include dirname(__FILE__).'/../../pwconfig.local.php';
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
| 25 |
{
|
| 26 |
private $_product = false;
|
| 28 |
private $_buttonEnabled = null;
|
| 29 |
private $_conversionToolsEnabled = null;
|
| 30 |
|
| 31 |
+
private $_widgetUrl = 'https://widget.pricewaiter.com';
|
| 32 |
+
private $_manageUrl = 'https://manage.pricewaiter.com';
|
| 33 |
+
private $_apiUrl = 'https://api.pricewaiter.com';
|
| 34 |
+
|
| 35 |
+
public function __construct()
|
| 36 |
+
{
|
| 37 |
+
if (!!defined('_PW_WIDGET_URL_')) {
|
| 38 |
+
$this->_widgetUrl = _PW_WIDGET_URL_;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if (!!defined('_PW_MANAGE_URL_')) {
|
| 42 |
+
$this->_manageUrl = _PW_MANAGE_URL_;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (!!defined('_PW_API_URL_')) {
|
| 46 |
+
$this->_apiUrl = _PW_API_URL_;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
public function isTesting()
|
| 51 |
{
|
| 52 |
return $this->_testing;
|
| 174 |
public function getButtonSettingsUrl()
|
| 175 |
{
|
| 176 |
$apiKey = Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
+
return sprintf("%s/stores/%s/button", $this->_manageUrl, $apiKey);
|
| 179 |
}
|
| 180 |
|
| 181 |
public function getWidgetUrl()
|
| 182 |
{
|
| 183 |
if ($this->isEnabledForStore()) {
|
| 184 |
+
return $this->_widgetUrl . '/script/'
|
| 185 |
. Mage::getStoreConfig('pricewaiter/configuration/api_key')
|
| 186 |
. ".js";
|
| 187 |
}
|
| 188 |
|
| 189 |
+
return $this->_widgetUrl . '/nyp/script/widget.js';
|
| 190 |
}
|
| 191 |
|
| 192 |
public function getApiUrl()
|
| 193 |
{
|
| 194 |
+
return $this->_apiUrl . '/1/order/verify?api_key='
|
| 195 |
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
| 196 |
}
|
| 197 |
|
| 382 |
|
| 383 |
return min($costs);
|
| 384 |
}
|
| 385 |
+
|
| 386 |
+
public function setHeaders()
|
| 387 |
+
{
|
| 388 |
+
$magentoEdition = 'Magento ' . Mage::getEdition();
|
| 389 |
+
$magentoVersion = Mage::getVersion();
|
| 390 |
+
$extensionVersion = Mage::getConfig()->getNode()->modules->PriceWaiter_NYPWidget->version;
|
| 391 |
+
Mage::app()->getResponse()->setHeader('X-Platform', $magentoEdition, true);
|
| 392 |
+
Mage::app()->getResponse()->setHeader('X-Platform-Version', $magentoVersion, true);
|
| 393 |
+
Mage::app()->getResponse()->setHeader('X-Platform-Extension-Version', $extensionVersion, true);
|
| 394 |
+
|
| 395 |
+
return true;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
public function getCategoriesAsJSON($product)
|
| 399 |
+
{
|
| 400 |
+
$categorization = array();
|
| 401 |
+
$assignedCategories = $product->getCategoryCollection()
|
| 402 |
+
->addAttributeToSelect('name');
|
| 403 |
+
|
| 404 |
+
$baseUrl = Mage::app()->getStore()->getBaseUrl();
|
| 405 |
+
|
| 406 |
+
// Find the path (parents) of each category, and add their information
|
| 407 |
+
// to the categorization array
|
| 408 |
+
foreach ($assignedCategories as $assignedCategory) {
|
| 409 |
+
$parentCategories = array();
|
| 410 |
+
$path = $assignedCategory->getPath();
|
| 411 |
+
$parentIds = explode('/', $path);
|
| 412 |
+
array_shift($parentIds); // We don't care about the root category
|
| 413 |
+
|
| 414 |
+
$categoryModel = Mage::getModel('catalog/category');
|
| 415 |
+
foreach($parentIds as $parentCategoryId) {
|
| 416 |
+
$parentCategory = $categoryModel->load($parentCategoryId);
|
| 417 |
+
$parentCategoryUrl = preg_replace('/^\//', '', $parentCategory->getUrlPath());
|
| 418 |
+
|
| 419 |
+
$parentCategories[] = array(
|
| 420 |
+
'name' => $parentCategory->getName(),
|
| 421 |
+
'url' => $baseUrl . '/' . $parentCategoryUrl
|
| 422 |
+
);
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
$categorization[] = $parentCategories;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
return json_encode($categorization);
|
| 429 |
+
}
|
| 430 |
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Callback.php
CHANGED
|
@@ -39,31 +39,28 @@ class PriceWaiter_NYPWidget_Model_Callback
|
|
| 39 |
curl_setopt($ch, CURLOPT_POST, true);
|
| 40 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
$
|
| 45 |
-
|
| 46 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 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 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
}
|
| 65 |
|
| 66 |
-
try {
|
| 67 |
|
| 68 |
// First, determine the store that this order corresponds to.
|
| 69 |
// This is a new feature as of 1.2.2, so we need to make sure the API
|
|
@@ -282,6 +279,9 @@ class PriceWaiter_NYPWidget_Model_Callback
|
|
| 282 |
$order->sendNewOrderEmail();
|
| 283 |
}
|
| 284 |
|
|
|
|
|
|
|
|
|
|
| 285 |
// If this is a test order, cancel it to prevent it from any further processing.
|
| 286 |
if ($this->_test) {
|
| 287 |
$order->cancel();
|
|
@@ -309,6 +309,8 @@ class PriceWaiter_NYPWidget_Model_Callback
|
|
| 309 |
$this->_log("The Name Your Price Widget has created order #"
|
| 310 |
. $order->getIncrementId() . " with order ID " . $order->getId());
|
| 311 |
} catch (Exception $e) {
|
|
|
|
|
|
|
| 312 |
$this->_log("PriceWaiter Name Your Price Widget was unable to create order. Check log for details.");
|
| 313 |
$this->_log($e->getMessage());
|
| 314 |
}
|
| 39 |
curl_setopt($ch, CURLOPT_POST, true);
|
| 40 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
| 41 |
|
| 42 |
+
try {
|
| 43 |
+
// If PriceWaiter returns an invalid response
|
| 44 |
+
if (curl_exec($ch) == "1") {
|
| 45 |
+
$message = "The Name Your Price Widget has received a valid order notification.";
|
| 46 |
+
if ($this->_test) {
|
| 47 |
+
$message .= ' This is a TEST order that will be created and canceled.';
|
| 48 |
+
}
|
| 49 |
+
Mage::log($message);
|
| 50 |
+
$this->_log($message);
|
| 51 |
+
} else {
|
| 52 |
+
$message = "An invalid PriceWaiter order notification has been received.";
|
| 53 |
+
throw(new Exception($message));
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
// Verify that we have not already received this callback based on the `pricewaiter_id` field
|
| 57 |
+
$pricewaiterOrder = Mage::getModel('nypwidget/order');
|
| 58 |
+
$pricewaiterOrder->loadByPriceWaiterId($request['pricewaiter_id']);
|
| 59 |
+
if ($pricewaiterOrder->getId()) {
|
| 60 |
+
$message = "Received a duplicate order from the PriceWaiter Callback API. Ignoring.";
|
| 61 |
+
throw(new Exception($message));
|
| 62 |
+
}
|
|
|
|
| 63 |
|
|
|
|
| 64 |
|
| 65 |
// First, determine the store that this order corresponds to.
|
| 66 |
// This is a new feature as of 1.2.2, so we need to make sure the API
|
| 279 |
$order->sendNewOrderEmail();
|
| 280 |
}
|
| 281 |
|
| 282 |
+
// Add order Increment ID to response
|
| 283 |
+
Mage::app()->getResponse()->setHeader('X-Platform-Order-Id', $order->getIncrementId());
|
| 284 |
+
|
| 285 |
// If this is a test order, cancel it to prevent it from any further processing.
|
| 286 |
if ($this->_test) {
|
| 287 |
$order->cancel();
|
| 309 |
$this->_log("The Name Your Price Widget has created order #"
|
| 310 |
. $order->getIncrementId() . " with order ID " . $order->getId());
|
| 311 |
} catch (Exception $e) {
|
| 312 |
+
Mage::app()->getResponse()->setHeader('HTTP/1.0 500 Internal Server Error', 500, true);
|
| 313 |
+
Mage::app()->getResponse()->setHeader('X-Platform-Error', $e->getMessage(), true);
|
| 314 |
$this->_log("PriceWaiter Name Your Price Widget was unable to create order. Check log for details.");
|
| 315 |
$this->_log($e->getMessage());
|
| 316 |
}
|
app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php
CHANGED
|
@@ -27,6 +27,8 @@ class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Fron
|
|
| 27 |
return;
|
| 28 |
}
|
| 29 |
|
|
|
|
|
|
|
| 30 |
try {
|
| 31 |
$request = $this->getRequest()->getPost();
|
| 32 |
if (!array_key_exists('pricewaiter_id', $request)) {
|
| 27 |
return;
|
| 28 |
}
|
| 29 |
|
| 30 |
+
Mage::helper('nypwidget')->setHeaders();
|
| 31 |
+
|
| 32 |
try {
|
| 33 |
$request = $this->getRequest()->getPost();
|
| 34 |
if (!array_key_exists('pricewaiter_id', $request)) {
|
app/code/community/PriceWaiter/NYPWidget/controllers/ProductinfoController.php
CHANGED
|
@@ -24,6 +24,7 @@ class PriceWaiter_NYPWidget_ProductinfoController extends Mage_Core_Controller_F
|
|
| 24 |
// Ensure that we have received POST data
|
| 25 |
$requestBody = Mage::app()->getRequest()->getRawBody();
|
| 26 |
$postFields = Mage::app()->getRequest()->getPost();
|
|
|
|
| 27 |
|
| 28 |
if (count($postFields) == 0) {
|
| 29 |
$this->norouteAction();
|
| 24 |
// Ensure that we have received POST data
|
| 25 |
$requestBody = Mage::app()->getRequest()->getRawBody();
|
| 26 |
$postFields = Mage::app()->getRequest()->getPost();
|
| 27 |
+
Mage::helper('nypwidget')->setHeaders();
|
| 28 |
|
| 29 |
if (count($postFields) == 0) {
|
| 30 |
$this->norouteAction();
|
app/code/community/PriceWaiter/pwconfig.local.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
define('_PW_WIDGET_URL_', 'http://dockerhost:8006');
|
| 4 |
+
define('_PW_MANAGE_URL_', 'http://dockerhost:8007');
|
| 5 |
+
define('_PW_API_URL_', 'https://pw-estes-api.ngrok.com');
|
| 6 |
+
|
| 7 |
+
?>
|
app/design/frontend/base/default/layout/pricewaiter.xml
CHANGED
|
@@ -17,7 +17,8 @@
|
|
| 17 |
<layout>
|
| 18 |
<catalog_product_view>
|
| 19 |
<reference name="head">
|
| 20 |
-
<action method="
|
|
|
|
| 21 |
<name>pricewaiter/product-pages.js</name>
|
| 22 |
</action>
|
| 23 |
</reference>
|
| 17 |
<layout>
|
| 18 |
<catalog_product_view>
|
| 19 |
<reference name="head">
|
| 20 |
+
<action method="removeItem">
|
| 21 |
+
<type>js</type>
|
| 22 |
<name>pricewaiter/product-pages.js</name>
|
| 23 |
</action>
|
| 24 |
</reference>
|
app/design/frontend/base/default/template/pricewaiter/widget.phtml
CHANGED
|
@@ -61,9 +61,10 @@
|
|
| 61 |
}
|
| 62 |
};
|
| 63 |
|
|
|
|
|
|
|
| 64 |
var PriceWaiterRegularPrice = '<?php echo (float) $_product->getPrice(); ?>';
|
| 65 |
var PriceWaiterProductType = '<?php echo $_product->getTypeId(); ?>';
|
| 66 |
-
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
| 67 |
//]]>
|
| 68 |
</script>
|
| 69 |
<div class="name-your-price-widget"
|
|
@@ -87,4 +88,7 @@
|
|
| 87 |
</script>
|
| 88 |
<?php endif; ?>
|
| 89 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
| 90 |
<?php endif; ?>
|
| 61 |
}
|
| 62 |
};
|
| 63 |
|
| 64 |
+
var PriceWaiterCategories = <?php echo $helper->getCategoriesAsJSON($_product); ?>;
|
| 65 |
+
|
| 66 |
var PriceWaiterRegularPrice = '<?php echo (float) $_product->getPrice(); ?>';
|
| 67 |
var PriceWaiterProductType = '<?php echo $_product->getTypeId(); ?>';
|
|
|
|
| 68 |
//]]>
|
| 69 |
</script>
|
| 70 |
<div class="name-your-price-widget"
|
| 88 |
</script>
|
| 89 |
<?php endif; ?>
|
| 90 |
<?php endif; ?>
|
| 91 |
+
|
| 92 |
+
<script src="<?php echo $helper->getWidgetUrl(); ?>" async></script>
|
| 93 |
+
|
| 94 |
<?php endif; ?>
|
js/pricewaiter/product-pages.js
CHANGED
|
@@ -17,260 +17,6 @@
|
|
| 17 |
*/
|
| 18 |
|
| 19 |
(function() {
|
| 20 |
-
|
| 21 |
-
var getSimpleProductSku;
|
| 22 |
-
if (typeof PriceWaiterOptions === 'object') {
|
| 23 |
-
getSimpleProductSku = function() {
|
| 24 |
-
if (PriceWaiterProductType === 'configurable') {
|
| 25 |
-
spConfig.settings.each(function(setting) {
|
| 26 |
-
var options, productId, settingId;
|
| 27 |
-
settingId = setting.id.replace('attribute', '');
|
| 28 |
-
options = spConfig.config.attributes[settingId].options;
|
| 29 |
-
productId = options.find(function(option) {
|
| 30 |
-
return option.id === setting.value;
|
| 31 |
-
}).allowedProducts[0];
|
| 32 |
-
return PriceWaiter.setSKU(PriceWaiterIdToSkus[productId]);
|
| 33 |
-
});
|
| 34 |
-
}
|
| 35 |
-
return PriceWaiter.getSKU();
|
| 36 |
-
};
|
| 37 |
-
PriceWaiterOptions.onButtonClick = function(PriceWaiter, platformOnButtonClick) {
|
| 38 |
-
var productConfiguration, productForm;
|
| 39 |
-
if (!productAddToCartForm.validator.validate()) {
|
| 40 |
-
return false;
|
| 41 |
-
}
|
| 42 |
-
productForm = $('product_addtocart_form');
|
| 43 |
-
productConfiguration = productForm.serialize();
|
| 44 |
-
PriceWaiter.setMetadata('_magento_product_configuration', encodeURIComponent(productConfiguration));
|
| 45 |
-
PriceWaiter.setSKU(getSimpleProductSku());
|
| 46 |
-
return platformOnButtonClick();
|
| 47 |
-
};
|
| 48 |
-
PriceWaiterOptions.onload = function(PriceWaiter) {
|
| 49 |
-
var handleBundles, handleConfigurables, handleGrouped, handleSimples, simplesInput, simplesSelect;
|
| 50 |
-
simplesSelect = function(select, name) {
|
| 51 |
-
select.observe('change', function() {
|
| 52 |
-
PriceWaiter.setProductOption(name, select.options[select.selectedIndex].text);
|
| 53 |
-
});
|
| 54 |
-
};
|
| 55 |
-
simplesInput = function(select, name) {
|
| 56 |
-
if (select.type === 'text' || select.tagName === 'TEXTAREA') {
|
| 57 |
-
select.observe('change', function() {
|
| 58 |
-
PriceWaiter.setProductOption(name, select.value);
|
| 59 |
-
});
|
| 60 |
-
} else {
|
| 61 |
-
select.observe('change', function() {
|
| 62 |
-
var optionValue;
|
| 63 |
-
optionValue = select.next('span').select('label')[0].innerHTML;
|
| 64 |
-
optionValue = optionValue.replace(/\s*<span.*\/span>/, '');
|
| 65 |
-
PriceWaiter.setProductOption(name, optionValue);
|
| 66 |
-
});
|
| 67 |
-
}
|
| 68 |
-
};
|
| 69 |
-
handleSimples = function() {
|
| 70 |
-
var current, optionLabel, optionName, productCustomOptions, productForm;
|
| 71 |
-
if (typeof opConfig === 'undefined') {
|
| 72 |
-
return;
|
| 73 |
-
}
|
| 74 |
-
productForm = $('product_addtocart_form');
|
| 75 |
-
if (productForm.getInputs('file').length !== 0) {
|
| 76 |
-
console.log('The PriceWaiter Name Your Price Widget does not support upload file options.');
|
| 77 |
-
$$('div.name-your-price-widget').each(function(pww) {
|
| 78 |
-
pww.setStyle({
|
| 79 |
-
display: 'none'
|
| 80 |
-
});
|
| 81 |
-
});
|
| 82 |
-
}
|
| 83 |
-
PriceWaiter.originalOpen = PriceWaiter.open;
|
| 84 |
-
PriceWaiter.open = function() {
|
| 85 |
-
var innerSpan, priceElement, productPrice;
|
| 86 |
-
productPrice = 0;
|
| 87 |
-
priceElement = document.getElementsByRegex('^product-price-');
|
| 88 |
-
innerSpan = priceElement[0].select('span');
|
| 89 |
-
if (typeof innerSpan[0] === 'undefined') {
|
| 90 |
-
productPrice = priceElement[0].innerHTML;
|
| 91 |
-
} else {
|
| 92 |
-
productPrice = innerSpan[0].innerHTML;
|
| 93 |
-
}
|
| 94 |
-
PriceWaiter.setPrice(productPrice);
|
| 95 |
-
PriceWaiter.originalOpen();
|
| 96 |
-
};
|
| 97 |
-
productCustomOptions = $$('.product-custom-option');
|
| 98 |
-
for (current in productCustomOptions) {
|
| 99 |
-
if (!isNaN(parseInt(current, 10))) {
|
| 100 |
-
optionLabel = productCustomOptions[current].up('dd').previous('dt').select('label')[0];
|
| 101 |
-
optionName = optionLabel.innerHTML.replace(/^<em.*\/em>/, '');
|
| 102 |
-
if (optionLabel.hasClassName('required')) {
|
| 103 |
-
PriceWaiter.setProductOptionRequired(optionName);
|
| 104 |
-
}
|
| 105 |
-
switch (productCustomOptions[current].tagName) {
|
| 106 |
-
case 'SELECT':
|
| 107 |
-
simplesSelect(productCustomOptions[current], optionName);
|
| 108 |
-
break;
|
| 109 |
-
case 'INPUT':
|
| 110 |
-
case 'TEXTAREA':
|
| 111 |
-
simplesInput(productCustomOptions[current], optionName);
|
| 112 |
-
}
|
| 113 |
-
}
|
| 114 |
-
}
|
| 115 |
-
};
|
| 116 |
-
handleConfigurables = function() {
|
| 117 |
-
spConfig.settings.each(function(setting) {
|
| 118 |
-
var attributeId, optionName;
|
| 119 |
-
attributeId = $(setting).id;
|
| 120 |
-
attributeId = attributeId.replace(/attribute/, '');
|
| 121 |
-
optionName = spConfig.config.attributes[attributeId].label;
|
| 122 |
-
if ($(setting).hasClassName('required-entry') && typeof PriceWaiter.setProductOptionRequired === 'function') {
|
| 123 |
-
PriceWaiter.setProductOptionRequired(optionName, true);
|
| 124 |
-
}
|
| 125 |
-
Event.observe(setting, 'change', function(event) {
|
| 126 |
-
var optionValue;
|
| 127 |
-
PriceWaiter.setPrice((Number(spConfig.config.basePrice) || 0) + (Number(spConfig.reloadPrice()) || 0));
|
| 128 |
-
optionValue = setting.value !== '' ? setting.options[setting.selectedIndex].innerHTML : void 0;
|
| 129 |
-
if (optionValue === void 0) {
|
| 130 |
-
PriceWaiter.clearProductOption(optionName);
|
| 131 |
-
} else {
|
| 132 |
-
PriceWaiter.setProductOption(optionName, optionValue);
|
| 133 |
-
}
|
| 134 |
-
});
|
| 135 |
-
});
|
| 136 |
-
};
|
| 137 |
-
handleBundles = function() {
|
| 138 |
-
var bundleElements, bundleOption, key, matched, obj, opt, rePattern, requiredOptions;
|
| 139 |
-
requiredOptions = [];
|
| 140 |
-
bundleElements = document.getElementsByRegex('^bundle-option-');
|
| 141 |
-
rePattern = /\[(\d*)\]/;
|
| 142 |
-
for (bundleOption in bundleElements) {
|
| 143 |
-
if (!isNaN(parseInt(bundleOption, 10))) {
|
| 144 |
-
obj = bundleElements[bundleOption];
|
| 145 |
-
if (obj.hasClassName('required-entry') || obj.hasClassName('validate-one-required-by-name')) {
|
| 146 |
-
matched = rePattern.exec(obj.name);
|
| 147 |
-
requiredOptions.push(parseInt(matched[1], 10));
|
| 148 |
-
}
|
| 149 |
-
}
|
| 150 |
-
}
|
| 151 |
-
requiredOptions = requiredOptions.uniq();
|
| 152 |
-
for (key in bundle.config.options) {
|
| 153 |
-
if (requiredOptions.indexOf(parseInt(key, 10)) > -1) {
|
| 154 |
-
opt = bundle.config.options[key];
|
| 155 |
-
PriceWaiter.setProductOptionRequired(opt.title, true);
|
| 156 |
-
}
|
| 157 |
-
}
|
| 158 |
-
document.observe('bundle:reload-price', function(event) {
|
| 159 |
-
var bOptions, bSelected, current, currentSelected, qty, selectedValue;
|
| 160 |
-
PriceWaiter.setPrice(event.memo.priceInclTax + event.memo.bundle.config.basePrice);
|
| 161 |
-
bSelected = event.memo.bundle.config.selected;
|
| 162 |
-
bOptions = event.memo.bundle.config.options;
|
| 163 |
-
for (current in bSelected) {
|
| 164 |
-
if (isNaN(current)) {
|
| 165 |
-
continue;
|
| 166 |
-
}
|
| 167 |
-
currentSelected = bSelected[current];
|
| 168 |
-
if (currentSelected.length === 0) {
|
| 169 |
-
PriceWaiter.clearProductOption(bOptions[current].title);
|
| 170 |
-
} else {
|
| 171 |
-
qty = bOptions[current].selections[currentSelected].qty;
|
| 172 |
-
selectedValue = bOptions[current].selections[currentSelected].name;
|
| 173 |
-
if (qty > 1) {
|
| 174 |
-
selectedValue += ' - Quantity: ' + qty;
|
| 175 |
-
}
|
| 176 |
-
PriceWaiter.setProductOption(bOptions[current].title, selectedValue);
|
| 177 |
-
}
|
| 178 |
-
}
|
| 179 |
-
});
|
| 180 |
-
if (typeof bundle !== 'undefined') {
|
| 181 |
-
bundle.reloadPrice();
|
| 182 |
-
}
|
| 183 |
-
};
|
| 184 |
-
handleGrouped = function() {
|
| 185 |
-
var productRows, productTable, row;
|
| 186 |
-
productTable = $$('table.grouped-items-table')[0];
|
| 187 |
-
productRows = productTable.select('tbody')[0];
|
| 188 |
-
productRows = productRows.childElements();
|
| 189 |
-
if (productRows.length > 0) {
|
| 190 |
-
PriceWaiter.setProductOptionRequired('Quantity of Products', true);
|
| 191 |
-
}
|
| 192 |
-
for (row in productRows) {
|
| 193 |
-
if (!isNaN(parseInt(row, 10))) {
|
| 194 |
-
productRows[row].select('input.qty')[0].observe('change', function(event) {
|
| 195 |
-
var amountToRemove, inputName, pattern, previousQuantity, productID, productName, productPrice, qty;
|
| 196 |
-
qty = this.value;
|
| 197 |
-
pattern = /\[(.*)\]/;
|
| 198 |
-
inputName = this.name;
|
| 199 |
-
productID = pattern.exec(inputName);
|
| 200 |
-
productID = productID[1];
|
| 201 |
-
productName = window.PriceWaiterGroupedProductInfo[productID][0];
|
| 202 |
-
productPrice = window.PriceWaiterGroupedProductInfo[productID][1];
|
| 203 |
-
previousQuantity = PriceWaiter.getProductOptions()[productName + ' (' + productPrice + ')'];
|
| 204 |
-
amountToRemove = Number(previousQuantity * productPrice);
|
| 205 |
-
if (qty > 0) {
|
| 206 |
-
PriceWaiter.setProductOption(productName + ' (' + productPrice + ')', qty);
|
| 207 |
-
PriceWaiter.setPrice(Number(PriceWaiter.getPrice()) + Number(productPrice * qty));
|
| 208 |
-
} else {
|
| 209 |
-
PriceWaiter.clearProductOption(productName + ' (' + productPrice + ')');
|
| 210 |
-
}
|
| 211 |
-
if (previousQuantity > 0) {
|
| 212 |
-
PriceWaiter.setPrice(Number(PriceWaiter.getPrice() - amountToRemove));
|
| 213 |
-
}
|
| 214 |
-
if (Object.keys(PriceWaiter.getProductOptions()).length > 0) {
|
| 215 |
-
PriceWaiter.clearRequiredProductOptions();
|
| 216 |
-
} else {
|
| 217 |
-
PriceWaiter.setProductOptionRequired('Quantity of Products', true);
|
| 218 |
-
}
|
| 219 |
-
});
|
| 220 |
-
}
|
| 221 |
-
}
|
| 222 |
-
};
|
| 223 |
-
PriceWaiter.setRegularPrice(PriceWaiterRegularPrice);
|
| 224 |
-
document['getElementsByRegex'] = function(pattern) {
|
| 225 |
-
var arrElements, findRecursively, re;
|
| 226 |
-
arrElements = [];
|
| 227 |
-
re = new RegExp(pattern);
|
| 228 |
-
findRecursively = function(aNode) {
|
| 229 |
-
var idx;
|
| 230 |
-
if (!aNode) {
|
| 231 |
-
return;
|
| 232 |
-
}
|
| 233 |
-
if (aNode.id !== void 0 && aNode.id.search(re) !== -1) {
|
| 234 |
-
arrElements.push(aNode);
|
| 235 |
-
}
|
| 236 |
-
for (idx in aNode.childNodes) {
|
| 237 |
-
findRecursively(aNode.childNodes[idx]);
|
| 238 |
-
}
|
| 239 |
-
};
|
| 240 |
-
findRecursively(document);
|
| 241 |
-
return arrElements;
|
| 242 |
-
};
|
| 243 |
-
if ($('qty') !== null) {
|
| 244 |
-
$('qty').observe('change', function() {
|
| 245 |
-
PriceWaiter.setQuantity($('qty').value);
|
| 246 |
-
});
|
| 247 |
-
}
|
| 248 |
-
switch (PriceWaiterProductType) {
|
| 249 |
-
case 'simple':
|
| 250 |
-
handleSimples();
|
| 251 |
-
break;
|
| 252 |
-
case 'configurable':
|
| 253 |
-
handleConfigurables();
|
| 254 |
-
break;
|
| 255 |
-
case 'bundle':
|
| 256 |
-
handleBundles();
|
| 257 |
-
break;
|
| 258 |
-
case 'grouped':
|
| 259 |
-
handleGrouped();
|
| 260 |
-
}
|
| 261 |
-
};
|
| 262 |
-
}
|
| 263 |
-
if (window.PriceWaiterWidgetUrl) {
|
| 264 |
-
(function() {
|
| 265 |
-
var pw, s;
|
| 266 |
-
pw = document.createElement('script');
|
| 267 |
-
pw.type = 'text/javascript';
|
| 268 |
-
pw.src = window.PriceWaiterWidgetUrl;
|
| 269 |
-
pw.async = true;
|
| 270 |
-
s = document.getElementsByTagName('script')[0];
|
| 271 |
-
s.parentNode.insertBefore(pw, s);
|
| 272 |
-
})();
|
| 273 |
-
}
|
| 274 |
-
});
|
| 275 |
|
| 276 |
}).call(this);
|
| 17 |
*/
|
| 18 |
|
| 19 |
(function() {
|
| 20 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
}).call(this);
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>nypwidget</name>
|
| 4 |
-
<version>2.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>
|
|
@@ -13,12 +13,12 @@
|
|
| 13 |
<author>
|
| 14 |
<name>PriceWaiter</name>
|
| 15 |
<user>pricewaiter</user>
|
| 16 |
-
<email>
|
| 17 |
</author>
|
| 18 |
</authors>
|
| 19 |
-
<date>2015-
|
| 20 |
-
<time>
|
| 21 |
-
<contents><target name="mageweb"><dir name="app"><dir name="etc"><dir name="modules"><file name="PriceWaiter_NYPWidget.xml" hash="72be18d9a8a741abc8926866449619cd"/></dir></dir><dir name="code"><dir name="community"><dir name="PriceWaiter"><dir name="NYPWidget"><dir name="Block"><dir name="Adminhtml"><file name="Link.php" hash="848a4e3813a3d238cacdd812334bb780"/><file name="Signup.php" hash="35a2739246307b5c7a3b69780a7f31fd"/><file name="Widget.php" hash="b781daf1de34d7856de7faba65afe414"/></dir><file name="Category.php" hash="de6397a45d7deabc803bef83a83d6b9a"/><file name="Widget.php" hash="193d694c4acc2133d8402f1e59d4dc25"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PricewaiterController.php" hash="27e17f05c8e2b2edcc28230185334f35"/></dir><file name="CallbackController.php" hash="
|
| 22 |
<compatible/>
|
| 23 |
<dependencies>
|
| 24 |
<required>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>nypwidget</name>
|
| 4 |
+
<version>2.1.2</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>
|
| 13 |
<author>
|
| 14 |
<name>PriceWaiter</name>
|
| 15 |
<user>pricewaiter</user>
|
| 16 |
+
<email>extensions@pricewaiter.com</email>
|
| 17 |
</author>
|
| 18 |
</authors>
|
| 19 |
+
<date>2015-11-04</date>
|
| 20 |
+
<time>23:58:54</time>
|
| 21 |
+
<contents><target name="mageweb"><dir name="app"><dir name="etc"><dir name="modules"><file name="PriceWaiter_NYPWidget.xml" hash="72be18d9a8a741abc8926866449619cd"/></dir></dir><dir name="code"><dir name="community"><dir name="PriceWaiter"><dir name="NYPWidget"><dir name="Block"><dir name="Adminhtml"><file name="Link.php" hash="848a4e3813a3d238cacdd812334bb780"/><file name="Signup.php" hash="35a2739246307b5c7a3b69780a7f31fd"/><file name="Widget.php" hash="b781daf1de34d7856de7faba65afe414"/></dir><file name="Category.php" hash="de6397a45d7deabc803bef83a83d6b9a"/><file name="Widget.php" hash="193d694c4acc2133d8402f1e59d4dc25"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PricewaiterController.php" hash="27e17f05c8e2b2edcc28230185334f35"/></dir><file name="CallbackController.php" hash="4c45b3d73999c3e69a11538b99b3b3fd"/><file name="ProductinfoController.php" hash="62780d33252c907cd48f9ff3326b3e8b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="dff2f6de0dacaf5a933048fa4a347f2f"/><file name="config.xml" hash="739770ab608f83b7625f8059f3050957"/><file name="system.xml" hash="82bb83cf7eb6a1d0ebf6bb774cd24414"/></dir><dir name="Helper"><file name="Data.php" hash="0e66b1bc250f25d4e3000446f7786d32"/></dir><dir name="Model"><file name="Callback.php" hash="60f99a9adf00f0615288d215c809ade1"/><file name="Category.php" hash="884685769be745cb273833ab7d691593"/><file name="Observer.php" hash="2399e210dd82633091570483f144bf12"/><file name="Order.php" hash="080844dcc4cf55d516abe27175a3a62a"/><file name="PaymentMethod.php" hash="386134e1ac803580222263523f0ced31"/><dir name="Carrier"><file name="ShippingMethod.php" hash="43a6ec1ad462797a5359238dcf9a749d"/></dir><dir name="Display"><file name="Phrase.php" hash="5b595a42b487930154c505a8e9a1301c"/><file name="Size.php" hash="8a596164268f48c3c034274550b13b96"/></dir><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="45eaa532cd5935b69102b8969da848fa"/></dir><file name="Category.php" hash="f4e761813ec4bb81d919f30895ce3578"/><file name="Order.php" hash="c08b340cec16bf774a7c178726dee0ac"/><dir name="Order"><file name="Collection.php" hash="4dc5b344274c0e5a391a24864fd1c003"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="d63678e9cc718ee87e8db3ca5163a8fd"/></dir></dir></dir></dir><dir name="sql"><dir name="nypwidget_setup"><file name="mysql4-install-1.0.0.php" hash="cd1b7892e75e4452ee94afbbefb4de6e"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="d1ae05f5cbe4a8f833e92b9f49d395db"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="bd342c802f6c91de6f9f51b0a4a25414"/><file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="b1ced0226bef6e950e026402b933872f"/><file name="mysql4-upgrade-1.3.0-1.3.1.php" hash="106b36065c125be31fc67424d80acdd4"/></dir></dir></dir><file name="pwconfig.local.php" hash="eadf90b58e89e54f991e20c2de3fc747"/></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="9e06026a8a820224336de4c9a7dde3fd"/></dir><dir name="template"><dir name="pricewaiter"><file name="categorytab.phtml" hash="d1d2c333cc9b18c909a44d333d8ab077"/><file name="signup.phtml" hash="fc18c669c18c55cccdf2c66c96199dec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="ab65e8c99c560997d403a780295a47da"/></dir><dir name="template"><dir name="pricewaiter"><file name="widget.phtml" hash="2275ce7d629b604a08c73f3b7d53bdae"/></dir></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/></dir><file name="pricewaiter.css" hash="c4061169f3e505c28bd09924108ca0ad"/></dir></dir></dir></dir><dir name="js"><dir name="pricewaiter"><file name="product-pages.js" hash="073eb5cd568a3db8b3ab7f94d5ffba3c"/><file name="token.js" hash="dbaedb04a60982743949e16096ed7f58"/></dir></dir></target></contents>
|
| 22 |
<compatible/>
|
| 23 |
<dependencies>
|
| 24 |
<required>
|
