[-] MO : loyalty : #PSCFV-3764 : display points of default attribute
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17038 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -2638,6 +2638,22 @@ class ProductCore extends ObjectModel
|
||||
return (isset($row['id_product_attribute']) && $row['id_product_attribute']) ? (int)$row['id_product_attribute'] : 0;
|
||||
}
|
||||
|
||||
public function getDefaultIdProductAttribute()
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return 0;
|
||||
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT pa.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
WHERE pa.`id_product` = '.(int)$this->id.'
|
||||
AND pa.`default_on` = 1'
|
||||
);
|
||||
|
||||
return (isset($row['id_product_attribute']) && $row['id_product_attribute']) ? (int)$row['id_product_attribute'] : 0;
|
||||
}
|
||||
|
||||
public function getPriceWithoutReduct($notax = false, $id_product_attribute = false)
|
||||
{
|
||||
return Product::getPriceStatic((int)$this->id, !$notax, $id_product_attribute, 6, null, false, false);
|
||||
|
||||
@@ -92,9 +92,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->getIdProductAttributeMostExpensive())), 2, '.', '');
|
||||
$cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', '');
|
||||
else
|
||||
$cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)($newProduct->getIdProductAttributeMostExpensive())), 2, '.', '');
|
||||
$cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', '');
|
||||
$cartProductsNew['cart_quantity'] = 1;
|
||||
$cartProducts[] = $cartProductsNew;
|
||||
}
|
||||
|
||||
@@ -432,15 +432,15 @@ class Loyalty extends Module
|
||||
public function hookExtraRight($params)
|
||||
{
|
||||
include_once(dirname(__FILE__).'/LoyaltyModule.php');
|
||||
|
||||
|
||||
$product = new Product((int)Tools::getValue('id_product'));
|
||||
if (Validate::isLoadedObject($product))
|
||||
{
|
||||
if (Validate::isLoadedObject($params['cart']))
|
||||
{
|
||||
$pointsBefore = (int)(LoyaltyModule::getCartNbPoints($params['cart']));
|
||||
$pointsAfter = (int)(LoyaltyModule::getCartNbPoints($params['cart'], $product));
|
||||
$points = (int)(LoyaltyModule::getNbPointsByPrice($product->getPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, (int)($product->getIdProductAttributeMostExpensive()))));
|
||||
$pointsBefore = (int)LoyaltyModule::getCartNbPoints($params['cart']);
|
||||
$pointsAfter = (int)LoyaltyModule::getCartNbPoints($params['cart'], $product);
|
||||
$points = (int)($pointsAfter - $pointsBefore);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -450,13 +450,19 @@ class Loyalty extends Module
|
||||
$this->smarty->assign('no_pts_discounted', 1);
|
||||
}
|
||||
else
|
||||
$points = (int)(LoyaltyModule::getNbPointsByPrice($product->getPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, (int)($product->getIdProductAttributeMostExpensive()))));
|
||||
$points = (int)LoyaltyModule::getNbPointsByPrice(
|
||||
$product->getPrice(
|
||||
Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true,
|
||||
(int)$product->getDefaultIdProductAttribute()
|
||||
)
|
||||
);
|
||||
|
||||
$pointsAfter = $points;
|
||||
$pointsBefore = 0;
|
||||
}
|
||||
$this->smarty->assign(array(
|
||||
'points' => (int)($points),
|
||||
'total_points' => (int)($pointsAfter),
|
||||
'points' => (int)$points,
|
||||
'total_points' => (int)$pointsAfter,
|
||||
'point_rate' => Configuration::get('PS_LOYALTY_POINT_RATE'),
|
||||
'point_value' => Configuration::get('PS_LOYALTY_POINT_VALUE'),
|
||||
'points_in_cart' => (int)$pointsBefore,
|
||||
|
||||
Reference in New Issue
Block a user