// Context part 27
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7812 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -104,9 +104,8 @@ class LoyaltyModule extends ObjectModel
|
||||
{
|
||||
if (!(int)(Configuration::get('PS_LOYALTY_NONE_AWARD')) AND Product::isDiscounted((int)$product['id_product']))
|
||||
{
|
||||
global $smarty;
|
||||
if (isset($smarty) AND is_object($newProduct) AND $product['id_product'] == $newProduct->id)
|
||||
$smarty->assign('no_pts_discounted', 1);
|
||||
if (isset($this->context->smarty) AND is_object($newProduct) AND $product['id_product'] == $newProduct->id)
|
||||
$this->context->smarty->assign('no_pts_discounted', 1);
|
||||
continue;
|
||||
}
|
||||
$total += ($taxesEnabled == PS_TAX_EXC ? $product['price'] : $product['price_wt'])* (int)($product['cart_quantity']);
|
||||
@@ -120,23 +119,17 @@ class LoyaltyModule extends ObjectModel
|
||||
|
||||
public static function getVoucherValue($nbPoints, $id_currency = NULL)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (empty($id_currency))
|
||||
$id_currency = (int)$cookie->id_currency;
|
||||
|
||||
return (int)$nbPoints * (float)Tools::convertPrice(Configuration::get('PS_LOYALTY_POINT_VALUE'), new Currency((int)$id_currency));
|
||||
$currency = $id_currency ? new Currency($id_currency) : $this->context->currency->id;
|
||||
|
||||
return (int)$nbPoints * (float)Tools::convertPrice(Configuration::get('PS_LOYALTY_POINT_VALUE'), $currency);
|
||||
}
|
||||
|
||||
public static function getNbPointsByPrice($price)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (Configuration::get('PS_CURRENCY_DEFAULT') != $cookie->id_currency)
|
||||
if (Configuration::get('PS_CURRENCY_DEFAULT') != $this->context->currency->id)
|
||||
{
|
||||
$currency = new Currency((int)($cookie->id_currency));
|
||||
if ($currency->conversion_rate)
|
||||
$price = $price / $currency->conversion_rate;
|
||||
if ($this->context->currency->conversion_rate)
|
||||
$price = $price / $this->context->currency->conversion_rate;
|
||||
}
|
||||
|
||||
/* Prevent division by zero */
|
||||
|
||||
@@ -243,13 +243,11 @@ class Loyalty extends Module
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->instanceDefaultStates();
|
||||
$this->_postProcess();
|
||||
|
||||
$categories = Category::getCategories((int)($cookie->id_lang));
|
||||
$order_states = OrderState::getOrderStates((int)$cookie->id_lang);
|
||||
$categories = Category::getCategories($this->context->language->id);
|
||||
$order_states = OrderState::getOrderStates($this->context->language->id);
|
||||
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
|
||||
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$languages = Language::getLanguages(false);
|
||||
@@ -442,8 +440,6 @@ class Loyalty extends Module
|
||||
{
|
||||
include_once(dirname(__FILE__).'/LoyaltyModule.php');
|
||||
|
||||
global $smarty;
|
||||
|
||||
$product = new Product((int)Tools::getValue('id_product'));
|
||||
if (Validate::isLoadedObject($product))
|
||||
{
|
||||
@@ -458,14 +454,14 @@ class Loyalty extends Module
|
||||
if (!(int)(Configuration::get('PS_LOYALTY_NONE_AWARD')) AND Product::isDiscounted((int)$product->id))
|
||||
{
|
||||
$points = 0;
|
||||
$smarty->assign('no_pts_discounted', 1);
|
||||
$this->context->smarty->assign('no_pts_discounted', 1);
|
||||
}
|
||||
else
|
||||
$points = (int)(LoyaltyModule::getNbPointsByPrice($product->getPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, (int)($product->getIdProductAttributeMostExpensive()))));
|
||||
$pointsAfter = $points;
|
||||
$pointsBefore = 0;
|
||||
}
|
||||
$smarty->assign(array(
|
||||
$this->context->smarty->assign(array(
|
||||
'points' => (int)($points),
|
||||
'total_points' => (int)($pointsAfter),
|
||||
'point_rate' => Configuration::get('PS_LOYALTY_POINT_RATE'),
|
||||
@@ -521,12 +517,10 @@ class Loyalty extends Module
|
||||
{
|
||||
include_once(dirname(__FILE__).'/LoyaltyModule.php');
|
||||
|
||||
global $smarty;
|
||||
|
||||
if (Validate::isLoadedObject($params['cart']))
|
||||
{
|
||||
$points = LoyaltyModule::getCartNbPoints($params['cart']);
|
||||
$smarty->assign(array(
|
||||
$this->context->smarty->assign(array(
|
||||
'points' => (int)$points,
|
||||
'voucher' => LoyaltyModule::getVoucherValue((int)$points),
|
||||
'guest_checkout' => (int)Configuration::get('PS_GUEST_CHECKOUT_ENABLED')
|
||||
|
||||
Reference in New Issue
Block a user