From 1e7243c023c2648a45b45d94ed88787335ba167e Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Fri, 9 Sep 2016 17:19:12 +0200 Subject: [PATCH] checking orders addition --- modules/paypal/paypal.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/paypal/paypal.php b/modules/paypal/paypal.php index 083ab636..211e3b88 100755 --- a/modules/paypal/paypal.php +++ b/modules/paypal/paypal.php @@ -543,10 +543,17 @@ class PayPal extends PaymentModule { $cart = $this->context->cart; $orders_with_delivery_address = Db::getInstance()->getValue(' - SELECT COUNT(`id_order`) - FROM `'._DB_PREFIX_.'orders - WHERE `id_address_delivery` = '.(int)$cart->id_address_delivery.' - AND `id_customer` = '.(int)$cart->id_customer.' + SELECT COUNT(`o.id_order`) + FROM `'._DB_PREFIX_.'orders` o + WHERE o.`id_address_delivery` = '.(int)$cart->id_address_delivery.' + AND o.`id_customer` = '.(int)$cart->id_customer.' + AND ( + o.valid = 1 + OR ( + o.valid = 0 + AND (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) NOT IN (6,8,15,16,18) + ) + ) '); $this->context->smarty->assign('accounts', (($orders_with_delivery_address==0)?array():$this->getBillingAgreement($cart->id_customer))); $this->getTranslations();