From 427258606cafb49bee087bba88d6303e0ea41412 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 27 Feb 2018 14:36:05 +0100 Subject: [PATCH] CS --- modules/invite/invite-program.php | 2 +- modules/invite/invite.php | 53 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/modules/invite/invite-program.php b/modules/invite/invite-program.php index ae1259b4..a9cfdafd 100644 --- a/modules/invite/invite-program.php +++ b/modules/invite/invite-program.php @@ -244,7 +244,7 @@ if ($oi_enable = Configuration::get('INVITE_OPENINVITER_ENABLE')) { $display_credits = false; $sql = 'SELECT id_customer FROM `'._DB_PREFIX_.'customer_credits` WHERE id_customer = ' . (int)$customer->id; -if (Db::getInstance()->getValue($sql) === false){ +if (Db::getInstance()->getValue($sql) === false) { $display_credits = true; } diff --git a/modules/invite/invite.php b/modules/invite/invite.php index 998d3463..855c74f4 100644 --- a/modules/invite/invite.php +++ b/modules/invite/invite.php @@ -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'); } } }