Merge branch 'ticket-14526-LoyaltyPaymentError' into develop
This commit is contained in:
commit
7b78add4b8
@ -233,15 +233,17 @@ class LoyaltyModule extends ObjectModel
|
|||||||
SELECT f.id_order AS id, f.date_add AS date, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
|
SELECT f.id_order AS id, f.date_add AS date, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
|
||||||
FROM `'._DB_PREFIX_.'loyalty` f
|
FROM `'._DB_PREFIX_.'loyalty` f
|
||||||
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
|
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
|
||||||
LEFT JOIN `ps_order_state_current` oc ON (oc.id_order = f.id_order)
|
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = f.`id_order`)
|
||||||
WHERE f.id_customer = '.(int)($id_customer).'
|
WHERE f.id_customer = '.(int)($id_customer).'
|
||||||
|
AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = f.`id_order` GROUP BY moh.`id_order`)
|
||||||
|
AND oh.`id_order_state` != 8
|
||||||
'.(($onlyValidate)? '' : ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
|
'.(($onlyValidate)? '' : ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
|
||||||
if ($onlyValidate) {
|
if ($onlyValidate) {
|
||||||
$query .= ' AND (f.id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' OR f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId().')';
|
$query .= ' AND (f.id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' OR f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId().')';
|
||||||
} elseif ($onlyDefault){
|
} elseif ($onlyDefault){
|
||||||
$query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getDefaultId();
|
$query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getDefaultId();
|
||||||
}
|
}
|
||||||
$query .= ' AND oc.`id_order_state` != 8 GROUP BY f.id_loyalty '.
|
$query .= ' GROUP BY f.id_loyalty '.
|
||||||
($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : '');
|
($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : '');
|
||||||
|
|
||||||
return Db::getInstance()->ExecuteS($query);
|
return Db::getInstance()->ExecuteS($query);
|
||||||
|
Loading…
Reference in New Issue
Block a user