Permalink
Browse files

Fixed percentages.

Sometime between the end of June and beginning of July Woot! changed from a decimal representation of percent sold (0.00-1.00) to an integer representation (0-100).
  • Loading branch information...
DarkstarDev committed Jul 17, 2012
1 parent 7a94bbe commit 5608cc0af9044baa2f351111856efc0b1376b827
Showing with 5 additions and 5 deletions.
  1. +2 −2 application/views/scripts/item/view.phtml
  2. +1 −1 library/Ds/Service/WootFeed.php
  3. +2 −2 public/js/product-update.js
@@ -63,9 +63,9 @@
<?php $current = end($this->productData['history']); ?>
<?php if(empty($this->currentProduct) || $this->productData['id'] == $this->currentProduct['id']): ?>
<div id="buy-link">
- <?php if(!$current['sold_out'] && $current['percent_sold'] < .9): ?>
+ <?php if(!$current['sold_out'] && $current['percent_sold'] < 90): ?>
<a href="<?php echo $this->productData['purchase_url']; ?>">I want one!</a>
- <?php elseif(!$current['sold_out'] && $current['percent_sold'] >= .9): ?>
+ <?php elseif(!$current['sold_out'] && $current['percent_sold'] >= 90): ?>
<a href="<?php echo $this->productData['purchase_url']; ?>">I want one!<br />(They're almost gone!)</a>
<?php else: ?>
Sold out!
@@ -215,7 +215,7 @@ protected function _parseWootRss($xml)
$item['teaser'] = (string)$wootNamespace->teaser;
$history['comments'] = (int)$wootNamespace->comments;
$history['sold_out'] = (strtolower((string)$wootNamespace->soldout) == 'true') ? true : false;
- $history['percent_sold'] = (float)$wootNamespace->soldoutpercentage;
+ $history['percent_sold'] = (int)$wootNamespace->soldoutpercentage;
$history['updated'] = date('c');
$images['standard'] = (string)$wootNamespace->standardimage;
$images['detail'] = (string)$wootNamespace->detailimage;
@@ -33,15 +33,15 @@ socket.on('product', function (data) {
if (productData.history[0].sold_out) {
$('#buy-link').text('Sold out!');
} else {
- if (parseFloat(productData.history[0].percent_sold) >= .9) {
+ if (parseInt(productData.history[0].percent_sold) >= 90) {
$('#buy-link').html('<a href="'+ productData.purchase_url +'">'
+ "I want one!<br />(They're almost gone!)" +'</a>');
} else {
$('#buy-link').html('<a href="'+ productData.purchase_url +'">I want one!</a>');
}
}
if (productData.wootoff) {
- var percentLeft = Math.round((1-productData.history[0].percent_sold)*100);
+ var percentLeft = (100-productData.history[0].percent_sold);
if ($('#woot-off').length) {
$('#progress-bar-inner').css('width', percentLeft +'%');
$('#progress-percent').text(percentLeft + '%');

0 comments on commit 5608cc0

Please sign in to comment.