From 4312d241f341ad425e255259d253482ea7a3d725 Mon Sep 17 00:00:00 2001 From: Fabio Chelly Date: Fri, 8 Nov 2013 18:12:11 +0100 Subject: [PATCH] [-] MO :Fixed #PNM-1654 (Loyalty module) by using most expensive attribute instead of default one --- modules/loyalty/LoyaltyModule.php | 4 ++-- modules/loyalty/loyalty.php | 2 +- modules/loyalty/views/templates/hook/product.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/loyalty/LoyaltyModule.php b/modules/loyalty/LoyaltyModule.php index cb2c51974..7dc030a2b 100644 --- a/modules/loyalty/LoyaltyModule.php +++ b/modules/loyalty/LoyaltyModule.php @@ -101,9 +101,9 @@ class LoyaltyModule extends ObjectModel { $cartProductsNew['id_product'] = (int)$newProduct->id; if ($taxesEnabled == PS_TAX_EXC) - $cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', ''); + $cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', ''); else - $cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', ''); + $cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', ''); $cartProductsNew['cart_quantity'] = 1; $cartProducts[] = $cartProductsNew; } diff --git a/modules/loyalty/loyalty.php b/modules/loyalty/loyalty.php index 96b71f57e..640c08968 100644 --- a/modules/loyalty/loyalty.php +++ b/modules/loyalty/loyalty.php @@ -453,7 +453,7 @@ class Loyalty extends Module $points = (int)LoyaltyModule::getNbPointsByPrice( $product->getPrice( Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, - (int)$product->getDefaultIdProductAttribute() + (int)$product->getIdProductAttributeMostExpensive() ) ); diff --git a/modules/loyalty/views/templates/hook/product.tpl b/modules/loyalty/views/templates/hook/product.tpl index 63cd24db3..36d6c55ac 100644 --- a/modules/loyalty/views/templates/hook/product.tpl +++ b/modules/loyalty/views/templates/hook/product.tpl @@ -39,7 +39,7 @@ $(document).ready(function() { if (typeof(productPrice) == 'undefined' || typeof(productPriceWithoutReduction) == 'undefined') return; - var points = Math.round(productPrice / point_rate); + var points = {$points}; var total_points = points_in_cart + points; var voucher = total_points * point_value; if (!none_award && productPriceWithoutReduction != productPrice) {