Merge branch 'ticket/r16112-display-credit'

This commit is contained in:
Michael RICOIS 2018-02-27 16:17:18 +01:00
commit 63e1e1eae5
2 changed files with 31 additions and 28 deletions

View File

@ -242,10 +242,10 @@ if ($oi_enable = Configuration::get('INVITE_OPENINVITER_ENABLE')) {
$oi_services = $inviter->getPlugins();
}
$display_credits = true;
$display_credits = false;
$sql = 'SELECT id_customer FROM `'._DB_PREFIX_.'customer_credits` WHERE id_customer = ' . (int)$customer->id;
if (Db::getInstance()->getValue($sql)){
$display_credits = false;
if (Db::getInstance()->getValue($sql) === false) {
$display_credits = true;
}
$customer_credit = 0;

View File

@ -1647,33 +1647,36 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
{
global $cookie, $cart, $smarty;
if($cookie->isLogged() && $cart->getOrderTotal() > 0) {
if ($cookie->isLogged() && $cart->getOrderTotal() > 0) {
$customer = new Customer((int) $cookie->id_customer);
if(Validate::isLoadedObject($customer)) {
if(Configuration::get('INVITE_CREDIT_ENABLE') == 1) {
$credit = $this->_get_credit($customer->id, FALSE, FALSE, 'array');
$already_used = FALSE;
$d_prefix = Configuration::get('INVITE_DISCOUNT_PREFIX');
$d_prefix_l = strlen($d_prefix);
foreach($cart->getDiscounts(TRUE) as $d) {
if(substr($d['name'], 0, $d_prefix_l) == $d_prefix) {
$already_used = TRUE;
break;
if (Validate::isLoadedObject($customer)) {
if (Configuration::get('INVITE_CREDIT_ENABLE') == 1) {
$display_credits = false;
$sql = 'SELECT id_customer FROM `'._DB_PREFIX_.'customer_credits` WHERE id_customer = ' . (int)$customer->id;
if (Db::getInstance()->getValue($sql) === false) {
$display_credits = true;
}
if ($display_credits === true) {
$credit = $this->_get_credit($customer->id, FALSE, FALSE, 'array');
$already_used = FALSE;
$d_prefix = Configuration::get('INVITE_DISCOUNT_PREFIX');
$d_prefix_l = strlen($d_prefix);
foreach ($cart->getDiscounts(TRUE) as $d) {
if (substr($d['name'], 0, $d_prefix_l) == $d_prefix) {
$already_used = TRUE;
break;
}
}
if ($credit[0] > 0 && !$already_used) {
$smarty->assign(array(
'display_credits' => $display_credits,
'invite_credit' => $credit,
));
return $this->display(__FILE__, 'shopping-cart-credit.tpl');
}
}
$display_credits = true;
$sql = 'SELECT id_customer FROM `'._DB_PREFIX_.'customer_credits` WHERE id_customer = ' .(int) $customer->id;
if(Db::getInstance()->getValue($sql)){
$display_credits = false;
}
if($credit[0] > 0 && !$already_used) {
$smarty->assign(array(
'display_credits' => $display_credits,
'invite_credit' => $credit,
));
return $this->display(__FILE__, 'shopping-cart-credit.tpl');
}
}
}