[-] MO : #PSFV-532 - Fix bug on the module Loyalty - "points" are not upgrading on changing combination

This commit is contained in:
mDeflotte
2012-02-17 13:36:29 +00:00
parent 8a53019e6c
commit c32c7c9dd3
4 changed files with 52 additions and 6 deletions
+3 -2
View File
@@ -449,7 +449,7 @@ class Loyalty extends Module
$points = 0;
$this->smarty->assign('no_pts_discounted', 1);
}
else
else
$points = (int)(LoyaltyModule::getNbPointsByPrice($product->getPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, (int)($product->getIdProductAttributeMostExpensive()))));
$pointsAfter = $points;
$pointsBefore = 0;
@@ -460,7 +460,8 @@ class Loyalty extends Module
'point_rate' => Configuration::get('PS_LOYALTY_POINT_RATE'),
'point_value' => Configuration::get('PS_LOYALTY_POINT_VALUE'),
'points_in_cart' => (int)$pointsBefore,
'voucher' => LoyaltyModule::getVoucherValue((int)$pointsAfter)));
'voucher' => LoyaltyModule::getVoucherValue((int)$pointsAfter),
'none_award' => Configuration::get('PS_LOYALTY_NONE_AWARD')));
return $this->display(__FILE__, 'product.tpl');
}
@@ -23,7 +23,50 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
var point_rate = {$point_rate};
var point_value = {$point_value};
var points_in_cart = {$points_in_cart};
var none_award = {$none_award};
$(document).ready(function() {
// Force color "button" to fire event change
$('#color_to_pick_list').click(function() {
$('#color_pick_hidden').triggerHandler('change');
});
// Catch all attribute changeent of the product
$('.product_attributes input, .product_attributes select').change(function() {
if (typeof(productPrice) == 'undefined' || typeof(productPriceWithoutReduction) == 'undefined')
return;
var points = Math.round(productPrice / point_rate);
var total_points = points_in_cart + points;
var voucher = total_points * point_value;
if (!none_award && productPriceWithoutReduction != productPrice) {
$('#loyalty').html("{l s='No reward points for this product because there\'s already a discount.' mod='loyalty'}");
} else if (!points) {
$('#loyalty').html("{l s='No reward points for this product.' mod='loyalty'}");
} else {
var content = "{l s='By buying this product you can collect up to' mod='loyalty'} <b><span id=\"loyalty_points\">"+points+'</span> ';
if (points > 1)
content += "{l s='loyalty points' mod='loyalty'}</b>. ";
else
content += "{l s='loyalty point' mod='loyalty'}</b>. ";
content += "{l s='Your cart will total' mod='loyalty'} <b><span id=\"total_loyalty_points\">"+total_points+'</span> ';
if (total_points > 1)
content += "{l s='points' mod='loyalty'}";
else
content += "{l s='point' mod='loyalty'}";
content += "</b> {l s='that can be converted into a voucher of' mod='loyalty'} ";
content += '<span id="loyalty_price">'+formatCurrency(voucher, currencyFormat, currencySign, currencyBlank)+'</span>.';
$('#loyalty').html(content);
}
});
});
</script>
<p id="loyalty" class="align_justify">
{if $points}
{l s='By buying this product you can collect up to' mod='loyalty'} <b><span id="loyalty_points">{$points}</span>