[-] MO : Fixed double creation of vouchers in loyalty and some redirections #PNM-1317
This commit is contained in:
@@ -197,20 +197,23 @@ class LoyaltyModule extends ObjectModel
|
||||
if (!Validate::isLoadedObject($cartRule))
|
||||
die(Tools::displayError('Incorrect object CartRule.'));
|
||||
$items = self::getAllByIdCustomer((int)$cartRule->id_customer, NULL, true);
|
||||
$associated = false;
|
||||
foreach ($items AS $item)
|
||||
{
|
||||
$f = new LoyaltyModule((int)$item['id_loyalty']);
|
||||
$lm = new LoyaltyModule((int)$item['id_loyalty']);
|
||||
|
||||
/* Check for negative points for this order */
|
||||
$negativePoints = (int)Db::getInstance()->getValue('SELECT SUM(points) points FROM '._DB_PREFIX_.'loyalty WHERE id_order = '.(int)$f->id_order.' AND id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' AND points < 0');
|
||||
|
||||
if ($f->points + $negativePoints <= 0)
|
||||
if ($lm->points + $negativePoints <= 0)
|
||||
continue;
|
||||
|
||||
$f->id_cart_rule = (int)$cartRule->id;
|
||||
$f->id_loyalty_state = (int)LoyaltyStateModule::getConvertId();
|
||||
$f->save();
|
||||
$lm->id_cart_rule = (int)$cartRule->id;
|
||||
$lm->id_loyalty_state = (int)LoyaltyStateModule::getConvertId();
|
||||
$lm->save();
|
||||
$associated = true;
|
||||
}
|
||||
return $associated;
|
||||
}
|
||||
|
||||
public static function getOrdersByIdDiscount($id_cart_rule)
|
||||
|
||||
Reference in New Issue
Block a user