[-] MO : #PSFV-532 - Fix bug on the module Loyalty - "points" are not upgrading on changing combination
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -1718,7 +1718,8 @@ ul#suppliers_list li .right_side {float:right;}
|
||||
#product p#loyalty {
|
||||
padding:10px 0 0 20px;
|
||||
border-top:1px solid #ccc;
|
||||
background:url(../img/icon/info.png) no-repeat 0 8px
|
||||
background:url(../img/icon/info.png) no-repeat 0 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#footer .myaccount li.loyalty img {display:none}
|
||||
|
||||
@@ -345,17 +345,17 @@ function updateDisplay()
|
||||
var taxExclPrice = (display_specific_price ? (specific_currency ? display_specific_price : display_specific_price * currencyRate) : priceTaxExclWithoutGroupReduction) + selectedCombination['price'] * currencyRate;
|
||||
|
||||
if (display_specific_price)
|
||||
var productPriceWithoutReduction = priceTaxExclWithoutGroupReduction + selectedCombination['price'] * currencyRate;
|
||||
productPriceWithoutReduction = priceTaxExclWithoutGroupReduction + selectedCombination['price'] * currencyRate; // Need to be global => no var
|
||||
|
||||
if (!displayPrice && !noTaxForThisProduct)
|
||||
{
|
||||
var productPrice = taxExclPrice * tax;
|
||||
productPrice = taxExclPrice * tax; // Need to be global => no var
|
||||
if (display_specific_price)
|
||||
productPriceWithoutReduction = ps_round(productPriceWithoutReduction * tax, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var productPrice = ps_round(taxExclPrice, 2);
|
||||
productPrice = ps_round(taxExclPrice, 2); // Need to be global => no var
|
||||
if (display_specific_price)
|
||||
productPriceWithoutReduction = ps_round(productPriceWithoutReduction, 2);
|
||||
}
|
||||
@@ -393,6 +393,7 @@ function updateDisplay()
|
||||
$('#our_price_display').text(formatCurrency(productPrice, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
|
||||
|
||||
|
||||
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
|
||||
if (productPriceWithoutReduction > productPrice)
|
||||
|
||||
Reference in New Issue
Block a user